-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error is thrown when a container doesn't exist #6
Comments
Hi @AlexChadwickP! Thank you for this identification. I concur that there should be some better validation and reporting on the presence of the supplied container name. Please feel free to take a stab at a PR! IMO a library like this should not create a resource without express consent from the user. The API parameter of This would look something like: if (allowCreateContainer && !exists) {
await containerClient.create();
}
if (!allowCreateContainer && !exists) {
throw new Error(`Container with name ${containerName} does not exist`);
} The natural place for this check would be within the Let me know if you require any assistance with this. Cheers, Andrew |
Hi Andrew, Thanks for the swift response, I'll fork it and attempt it today, I'll update this discussions with any questions that may arise! Cheers, Alex |
I'm having some trouble throwing an error since the code needed to check whether a container exists is async. I can't throw an error in Here's what I've attempted:
But without any success. As far as I'm aware Winston isn't using the async/await API so it makes asynchronous transports hard to work with. Have you got any ideas to work around this? |
I can see how this is cumbersome. Much of this library was written when async/await was not available. However, I believe that the async/await API is supported by Winston transports. Here is an example. You could attempt a re-write using async explicitly. This would be a bit of an undertaking, though. Another option could be to perform the check in the constructor and then mark the completion of the task with a side effect variable. There is an example of this within winston-bigquery. I am not a big fan of this approach as it lacks purity. IMO you are proceeding along the right path given the code you are working with. Perhaps try and use the I will dive into this myself and report back. |
@AlexChadwickP Marking |
I mean it's not a huge library so I don't think trying to migrate towards an |
Description
Currently if you supply a non-existent
containerName
towinstonAzureBlob
nothing will happen. The container isn't created (that I'm aware of) and there is no indication that the container should exist before hand.Suggestion
Check if the container exists (I'm not incredibly familiar with the Azure Blob SDK but this may be relevant: https://stackoverflow.com/questions/61128794/how-do-you-check-that-a-container-exists-in-azure-blob-storage-v12).
If it doesn't exist throw an error or an exception to indicate that this is the case.
Maybe you could also provide a
force
optional value to the object with all the configuration that will allow the application to attempt to create the container? E.g:What do you think?
I wouldn't mind giving this a shot myself when I get the chance (I'm using this at work so I could probably do so during working hours), unless you'd rather do it yourself?
Thanks for your time!
The text was updated successfully, but these errors were encountered: