Improve exception management when Blob does not exist
See original GitHub issueWhen a function is triggered through HTTP with a named parameter (e.g., userparam) and we have a blob binding with such parameter in the name and it does not exist, the runtime throws:
System.Private.CoreLib: Exception while executing function: Functions.test_missing_blob. System.Private.CoreLib: Result: Failure
Exception: AttributeError: 'NoneType' object has no attribute 'type'
Stack: File "...\azure-functions-core-tools\bin\workers\python\3.7\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 306, in _handle__invocation_request
pytype=pb_type_info.pytype)
File "...\azure_functions_worker\bindings\meta.py", line 63, in from_incoming_proto
return binding.decode(datum, trigger_metadata=metadata)
File "...\azure-functions-core-tools\bin\workers\python\3.7\windows\x64\azure\functions\blob.py", line 78, in decode
data_type = data.type
The definition of the function can be something like:
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
]
},
{
"name": "notebooksindexin",
"type": "blob",
"direction": "in",
"path": "file-{userparam}.json",
"connection":"AzureWebJobsStorage"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
The key here is to pass “userparam” such that “file-{userparam}.json” does not exist.
This eventually fails and returns a 500. However, I don’t think this is the most graceful behavior. My proposal would be to:
- Instead of waiting all the way to the dispatcher to get an empty “data” field, identify this early and log it in a friendly way.
- Surface it to the client with a full HTTP response that would say somewhere (maybe the body) that the blob is missing.
I am running the azure functions runtime locally and executing queries but I think that’s not relevant other than I should be able to test a possible solution fast.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Managing concurrency in Blob storage - Azure
Learn how to manage multiple writers to a blob by implementing either optimistic or pessimistic concurrency in your application.
Read more >The specified blob does not exist - Shows in azure browser
Opening the Azure Storage App and navigating to the container / blob; Right-click the blob and selecting "Properties..." Copy/paste the text ...
Read more >"The specified blob does not exist" while running the data ...
To resolve this issue, make sure the file with the same name which was used during the import exists in that directory or...
Read more >Error: HTTP status code=404, Exception=The specified ...
when a user tries to upload a file, snowflake does check before if the file already exists or not. If the file is...
Read more >Azure Storage Blobs .Net SDK v12 upgrade guide and tips
If you are not familiar with the Azure Blob Storage SDK already, read the quick start instead ... Download Json Text With Exception...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I think both cases should pass None. We want to let user code decide what to do because an error isn’t always the desired result. Here’s an example of another language (C# script) where it receives null if the file doesn’t exist and the function handles it by creating the file with a blob output: https://github.com/anthonychu/slack-user-change-alerts/blob/master/src/SlackUserChangeAlerts.Function/CheckUserListChanges/run.csx#L13
Just realized something, how will we know the name of the blob we attempted to fetch if all we get passed is
None
?