Azure / azure-functions-durable-python

Python library for using the Durable Functions bindings.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DurableOrchestrationContext call_http does not work with string input

nickholt15 opened this issue Β· comments

πŸ› Describe the bug

There is a logical error in the DurableOrchestrationContext call_http method.

https://github.com/Azure/azure-functions-durable-python/blob/dev/azure/durable_functions/models/DurableOrchestrationContext.py#L215

content is type hinted as a str, however it only works with dictionary input.

I noticed this error when turning on type checking within VS Code.

To satisfy the type checker, I tried piping the dictionary object through json.dumps(), but that led to an error during execution.

πŸ€” Expected behavior
This should work with either dictionary or string input. It only works with dictionary input.

β˜• Steps to reproduce
Construct an arbitrary payload with key-value pairs.

context.call_http(method='POST', content=payload, uri=my_uri) succeeds

context.call_http(method='POST', content=json.dumps(payload), uri=my_uri) fails

Line 239 is responsible for the error: https://github.com/Azure/azure-functions-durable-python/blob/dev/azure/durable_functions/models/DurableOrchestrationContext.py#L239

The line:

if content and content is not isinstance(content, str):

should instead be:

if content and not isinstance(content, str):

@nickholt15 Hey, I think I experienced the same problem: #478 you might want to have a look for details.

I am a little afraid to mark mine as a duplicate of yours, since I guess MS will then discard mine and will not have a look at the details (which as I think are really helpful). So I ask you, if you might want to tag yours as a duplicate of mine?