Skip to content

Python3.14 function app startup error due to type hint issue #596

Closed

Description

🐛 Describe the bug

After updating to Python 3.14 the function app was not able to start again (error message below).
Short error message:

cannot load the **** function: binding type "'client'" and dataType "durableClient" in the binding decorator do not match the corresponding function parameter's Python type annotation DurableOrchestrationClient .

azure-functions-durable version: 1.4.0 and 1.5.0

After some time debugging I was able to reveal the root cause. It is related to the Typehints.

# does not work
import azure.durable_functions as df
import azure.functions as func

@bp.event_grid_trigger(arg_name="azeventgrid")
@bp.durable_client_input(client_name="client")
async def my_function_name(
    azeventgrid: func.EventGridEvent, client: df.DurableOrchestrationClient
) -> None:
# the typehint df.DurableOrchestrationClient is the root cause
# does
import azure.durable_functions as df
import azure.functions as func

@bp.event_grid_trigger(arg_name="azeventgrid")
@bp.durable_client_input(client_name="client")
async def my_function_name(
    azeventgrid: func.EventGridEvent, client
) -> None:
# removing the type hint is solving the issue

Below the full error message:

Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Private.CoreLib: One or more errors occurred. (Result: Failure Type: Exception: FunctionLoadError: cannot load the ****function: binding type "'client'" and dataType "durableClient" in the binding decorator do not match the corresponding function parameter's Python type annotation DurableOrchestrationClient Stack: Traceback (most recent call last): File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 99, in worker_init_request load_function_metadata( ~~~~~~~~~~~~~~~~~~~~~~^ init_request.function_app_directory, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ caller_info="worker_init_request") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 410, in load_function_metadata _metadata_result = (index_functions(function_path, function_app_directory)) \ ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 420, in index_functions process_indexed_function( ~~~~~~~~~~~~~~~~~~~~~~~~^ protos, ^^^^^^^ _functions, ^^^^^^^^^^^ indexed_functions, ^^^^^^^^^^^^^^^^^^ function_dir)) ^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/loader.py", line 136, in process_indexed_function function_info = functions_registry.add_indexed_function( function=indexed_function, protos=protos) File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/functions.py", line 429, in add_indexed_function settlement_client_arg) = self.validate_function_params( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ params, ^^^^^^^ ...<2 lines>... func_name, ^^^^^^^^^^ protos) ^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/functions.py", line 270, in validate_function_params raise FunctionLoadError( ...<5 lines>... 'annotation ' + param_py_type.name) azure_functions_runtime.functions.FunctionLoadError: cannot load the **** function: binding type "'client'" and dataType "durableClient" in the binding decorator do not match the corresponding function parameter's Python type annotation DurableOrchestrationClient ). System.Private.CoreLib: Result: Failure Type: Exception: FunctionLoadError: cannot load the **** function: binding type "'client'" and dataType "durableClient" in the binding decorator do not match the corresponding function parameter's Python type annotation DurableOrchestrationClient Stack: Traceback (most recent call last): File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 99, in worker_init_request load_function_metadata( ~~~~~~~~~~~~~~~~~~~~~~^ init_request.function_app_directory, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ caller_info="worker_init_request") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 410, in load_function_metadata _metadata_result = (index_functions(function_path, function_app_directory)) \ ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/handle_event.py", line 420, in index_functions process_indexed_function( ~~~~~~~~~~~~~~~~~~~~~~~~^ protos, ^^^^^^^ _functions, ^^^^^^^^^^^ indexed_functions, ^^^^^^^^^^^^^^^^^^ function_dir)) ^^^^^^^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/loader.py", line 136, in process_indexed_function function_info = functions_registry.add_indexed_function( function=indexed_function, protos=protos) File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/functions.py", line 429, in add_indexed_function settlement_client_arg) = self.validate_function_params( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ params, ^^^^^^^ ...<2 lines>... func_name, ^^^^^^^^^^ protos) ^^^^^^^ File "/azure-functions-host/workers/python/3.14/LINUX/X64/azure_functions_runtime/functions.py", line 270, in validate_function_params raise FunctionLoadError( ...<5 lines>... 'annotation ' + param_py_type.name) azure_functions_runtime.functions.FunctionLoadError: cannot load the **** function: binding type "'client'" and dataType "durableClient" in the binding decorator do not match the corresponding function parameter's Python type annotation DurableOrchestrationClient .

🤔 Expected behavior

What should have happened?

The function should be able to startup without issues when using the type hint.

☕ Steps to reproduce

What Durable Functions patterns are you using, if any?
Any minimal reproducer we can use?
See above
Are you running this locally or on Azure?

On Azure

⚡If deployed to Azure

We have access to a lot of telemetry that can help with investigations. Please provide as much of the following information as you can to help us investigate!

  • Timeframe issue observed:
  • Function App name:
  • Function name(s):
  • Azure region:
  • Orchestration instance ID(s):
  • Azure storage account name:

If you don't want to share your Function App or storage account name GitHub, please at least share the orchestration instance ID. Otherwise it's extremely difficult to look up information.

There is no instance ID because the function was not able to start up

Activity

  1. ltwlf commented on Mar 16, 2026

    @ltwlf

    Same issue here. The AgentFunctionApp from agent-framework-azurefunctions (1.0.0b260311) also generates functions with df.DurableOrchestrationClient type annotations internally, making it impossible to use on Python 3.14. Workaround: pin to Python 3.13 (requires-python = '>=3.12,<3.14').

  2. nachogarcia commented on Jul 12, 2026

    @nachogarcia
    Contributor

    Summary

    On Python 3.14, every function decorated with @app.durable_client_input(...) fails to index in the Azure Functions Python worker with:

    FunctionLoadError: cannot load the <fn> function: binding type "'client'" and dataType "durableClient"
    in the binding decorator do not match the corresponding function parameter's Python type annotation
    DurableOrchestrationClient
    

    Because the client function fails to load, the host aborts startup (Microsoft.Azure.WebJobs.Script.ExternalStartupException: "Error building configuration in an external startup class.") and the entire function app returns HTTP 503 on every request.

    The root cause is that azure-functions-durable's rich-client binding relies on mutating func.__annotations__ and then re-wrapping the function with functools.wraps. On CPython 3.14 functools.wraps propagates __annotate__ instead of __annotations__ (deferred-annotation work, PEP 649 / PEP 749), so the annotation patch is silently reverted and the worker sees the real DurableOrchestrationClient type again.

    This regressed in 1.6.0, which added the Python 3.14 support/classifier in #608. 1.6.0 is currently the only released version carrying the Programming Language :: Python :: 3.14 classifier, so there is no fixed version to upgrade to.

    Environment

    azure-functions-durable 1.6.0 (released 2026-07-09; the release containing #608)
    azure-functions 2.2.0
    Python 3.14 (Azure Functions v4 runtime, Linux; also reproduced locally on CPython 3.14.0rc3)
    Programming model Python v2 (decorators)
    Last known-good Same code + azure-functions-durable==1.6.0 on Python 3.13

    Symptom (production)

    The app has HTTP-trigger functions that stack @app.route(...) over @app.durable_client_input(client_name="client"):

    @app.route(route="start-processing", methods=["POST"])
    @app.durable_client_input(client_name="client")
    async def http_start_processing(req: func.HttpRequest, client: df.DurableOrchestrationClient) -> func.HttpResponse:
        ...

    On the 3.14 worker these fail to index; the host then throws ExternalStartupException and returns 503 for all routes. The exact worker error (from Application Insights AppExceptions.InnermostMessage):

    Result: Failure
    Exception: FunctionLoadError: cannot load the http_start_processing function: binding type "'client'"
    and dataType "durableClient" in the binding decorator do not match the corresponding function
    parameter's Python type annotation DurableOrchestrationClient
    

    The same code deployed on Python 3.13 loads and runs correctly.

    Root cause

    DFApp._add_rich_client (in azure/durable_functions/decorators/durable_app.py) works around the worker's inability to type-check a rich client object by overwriting the parameter annotation to str, then wrapping the user function:

    def _add_rich_client(self, fb, parameter_name, client_constructor):
        # Obtain user-code and force type annotation on the client-binding parameter to be `str`.
        # This ensures a passing type-check of that specific parameter,
        # circumventing a limitation of the worker in type-checking rich DF Client objects.
        # TODO: Once rich-binding type checking is possible, remove the annotation change.
        user_code = fb._function._func
        user_code.__annotations__[parameter_name] = str
    
        @wraps(user_code)                       # functools.wraps
        async def df_client_middleware(*args, **kwargs):
            ...

    The function the worker ultimately indexes is df_client_middleware (the @wraps-ed wrapper), and it is that wrapper's annotations the worker reads to validate the durableClient binding.

    The functools.wraps behavior changed in CPython 3.14. functools.WRAPPER_ASSIGNMENTS now copies __annotate__ and no longer copies __annotations__:

    • Python ≤ 3.13: ('__module__', '__name__', '__qualname__', '__annotations__', '__doc__')
    • Python 3.14: ('__module__', '__name__', '__qualname__', '__doc__', '__annotate__', '__type_params__')

    Because the wrapper inherits the wrapped function's __annotate__ (which lazily recomputes the original source annotation), the earlier user_code.__annotations__[parameter_name] = str mutation is overridden. The wrapper's annotations resolve back to DurableOrchestrationClient, and the worker's binding/annotation check fails.

    Minimal, self-contained reproduction (no Azure host needed)

    # CPython 3.14
    import functools, annotationlib
    from annotationlib import Format
    
    class DurableOrchestrationClient: ...
    
    async def user_code(client: DurableOrchestrationClient): ...
    user_code.__annotations__["client"] = str          # what _add_rich_client does
    
    @functools.wraps(user_code)                          # what _add_rich_client does next
    async def wrapper(*a, **k): ...
    
    print(user_code.__annotations__)   # {'client': <class 'str'>}                  <- patched
    print(wrapper.__annotations__)     # {'client': <class '...DurableOrchestrationClient'>}  <- patch lost
    print(annotationlib.get_annotations(wrapper, format=Format.FORWARDREF))
                                       # {'client': <class '...DurableOrchestrationClient'>}
    print(functools.WRAPPER_ASSIGNMENTS)
                                       # ('__module__','__name__','__qualname__','__doc__','__annotate__','__type_params__')

    On Python 3.13 wrapper.__annotations__ is {'client': str} (the patch survives, because wraps copied __annotations__), which is why the same code loads there.

    Why #608's 3.14 validation didn't catch it

    #608 ("Patch dependency CVEs, drop Python 3.9, add Python 3.10–3.14 support") added the 3.14 classifier and a 3.14 CI leg, validated as "Test suite passes on 3.13 and 3.14: 309 passed." Those are the library's own unit tests; they don't run the function through the Azure Functions Python worker's indexing/binding-validation path, which is the only place the wrapper's annotations are read back to validate the durableClient binding. So the _add_rich_client + functools.wraps interaction on 3.14 was never exercised, and the 3.14 leg stayed green while real function apps fail to start.

    Impact

    • Any Python v2 function app using durable_client_input (i.e. essentially every Durable Functions client) fails to start on Python 3.14 and returns 503 for all routes.
    • 1.6.0 is the only release advertising 3.14 support, so there is no forward version to move to; affected apps must stay on Python 3.13.

    Suggested fix

    Apply the annotation override to the wrapper (after @wraps), and make it survive PEP 649 deferred annotations — e.g. set the wrapper's __annotations__ explicitly and clear its __annotate__ so both the dict-based and __annotate__-based readers agree:

    @wraps(user_code)
    async def df_client_middleware(*args, **kwargs):
        ...
    
    ann = dict(getattr(df_client_middleware, "__annotations__", {}))
    ann[parameter_name] = str
    df_client_middleware.__annotations__ = ann
    df_client_middleware.__annotate__ = None   # 3.14: stop __annotate__ from re-deriving the original

    (Verified on 3.14: with __annotate__ set to None and __annotations__ explicitly holding {parameter_name: str}, annotationlib.get_annotations(..., format=VALUE|FORWARDREF) both return str.) Alternatively, exclude __annotate__/__annotations__ from the wraps copy for this wrapper, or migrate off the annotation-mutation workaround entirely now that the worker supports SDK/deferred-binding types.

    Adding a CI leg that indexes a durable_client_input function through the actual Python worker on 3.14 would prevent regressions of this class.

    References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions