-
Notifications
You must be signed in to change notification settings - Fork 64
Description
π Describe the bug
The call_http
method of DurableOrchestrationContext
json serializes regular str
content.
π€ Expected behavior
It should NOT json serialize regular str
content, as the code suggests
β Steps to reproduce
What Durable Functions patterns are you using, if any?
N/A
Any minimal reproducer we can use?
The interesting block looks like:
def call_http(self, method: str, uri: str, content: Optional[str] = None,
...
if content and content is not isinstance(content, str):
json_content = json.dumps(content)
else:
json_content = content
and this does not seem to be quite right. If content = "foo"
the conditions after the if
will evaluate as follows:
content and (content (is not) isinstance(content, str)) # "is not" binds stronger than "and"
Truthy (and "foo" (is not) True )
True and ("foo" (is not) True)
True and True
True
I guess what you wanted was:
if content and not isinstance(content, str):
json_content = json.dumps(content)
else:
json_content = content
But if content = []
this will result in json_content = []
(in oposition to json_content = "[]"
), not sure if you would want that (at least I wouldnt). You might want to use something like this, instead:
if not isinstance(content, str):
try:
json_content = json.dumps(content)
except TypeError:
json_content = content
Since None
and []
might be desirable to put in content and are all json serializable (as null
and []
resp.).
Are you running this locally or on Azure?
Both
β‘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!
N/A
DF Version
v1.2.8