Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object of type generator is not JSON serializable error in orchestrator function #487

Open
ravihooda155 opened this issue Feb 26, 2024 · 0 comments
Labels

Comments

@ravihooda155
Copy link

In order to reuse piece of code within orchestrator function .Added below code for testing that part.
The behaviour of activity trigger part change when it is used in separate function other than orchestrator function.
It throws error Object of type generator is not JSON serializable error when used in some other test function and test function is used in orchestrator function.

It works fine when yield part is within orchestrator function

IS this the right way of implementing the usage of repetitive code in orchestrator function or we need sub orchestrators etc ?

def test(context: df.DurableOrchestrationContext,args):
    response = yield context.call_activity('hello', args)
    logging.info(response)
    return response

def orchestrator_function(context: df.DurableOrchestrationContext):

    response = yield context.call_activity('hello', args)
    logging.info(response)
    orchestrator_response =test(context,args)
    logging.info(orchestrator_response)

Hello is activity trigger return following dict
{'result': 'failure', 'response': 'Something went wrong.Internal server error', 'status_code': 500}

2024-02-26 11:40:28.312
{'result': 'failure', 'response': 'Something went wrong.Internal server error', 'status_code': 500}
Information
2024-02-26 11:40:28.312
<generator object test at 0x7ff2806fe500>
Information
2024-02-26 11:40:28.379
f1464adb297b452684b7b510dafc84f6: Function '_orchestrator (Orchestrator)' failed with an error. Reason: Message: Object of type generator is not JSON serializable, StackTrace: at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at Microsoft.Azure.WebJobs.Extensions.DurableTask.TaskOrchestrationShim.InvokeUserCodeAndHandleResults(RegisteredFunctionInfo orchestratorInfo, OrchestrationContext innerContext) in D:\a_work\1\s\src\WebJobs.Extensions.DurableTask\Listener\TaskOrchestrationShim.cs:line 150. IsReplay: False. State: Failed. RuntimeStatus: Failed. HubName: . AppName: . SlotName: Production. ExtensionVersion: 2.12.0. SequenceNumber: 5. TaskEventId: -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants