Skip to content

Commit a6146ae

Browse files
committed
Clarify missing client binding errors
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 76f2163a-0773-4889-b627-1bd4e5c7bea0
1 parent e17a597 commit a6146ae

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

azure-functions-durable/azure/durable_functions/decorators/durable_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ def attach_client_function(user_fn: Callable[..., Any]) -> FunctionBuilder:
411411
@wraps(function)
412412
async def client_bound(*args: Any, **kwargs: Any) -> Any:
413413
bound = signature.bind(*args, **kwargs)
414+
if client_name not in bound.arguments:
415+
raise TypeError(
416+
f"durable client binding parameter '{client_name}' is not "
417+
f"declared by function '{function.__name__}'")
414418
raw_client = bound.arguments[client_name]
415419
if not isinstance(raw_client, str):
416420
raise TypeError(

tests/azure-functions-durable/test_decorator_compat.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT License.
33

44
import azure.durable_functions as df
5+
import pytest
56
from azure.durable_functions.constants import (
67
ACTIVITY_TRIGGER,
78
DURABLE_CLIENT,
@@ -147,6 +148,17 @@ def starter(client):
147148
assert clients[0] is clients[1]
148149

149150

151+
async def test_durable_client_input_rejects_missing_binding_parameter():
152+
app = df.DFApp()
153+
154+
async def starter(other):
155+
return other
156+
157+
fb = app.durable_client_input(client_name="client")(starter)
158+
with pytest.raises(TypeError, match="binding parameter 'client' is not declared"):
159+
await fb._function._func(other="{}")
160+
161+
150162
# ---------------------------------------------------------------------------
151163
# All decorators register a function builder
152164
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)