Skip to content

Improve exception management when Blob does not exist #670

@goiri

Description

@goiri

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions