question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve exception management when Blob does not exist

See original GitHub issue

When 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:

  1. 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.
  2. 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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
anthonychucommented, May 9, 2020

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

0reactions
reubanocommented, May 24, 2022

Just realized something, how will we know the name of the blob we attempted to fetch if all we get passed is None?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found