Skip to content

wait_for_external_event Task result adds double quotes within the result attribute #295

@legendof-selda

Description

@legendof-selda

🐛 Raise Event adds " in result
When we raise an event from an activity, when picked up by the orchestrator function double quotes are added in result attribute.

The Orchestration function

def orchestrator_function(context: df.DurableOrchestrationContext):
  result = yield context.call_activity("CheckData", "blob_name")
  approval_code = yield context.call_activity("AskApproval", {"email": email, "instance_id": context.instance_id})
  timeout_task = context.create_timer(expiration)
  approval_approved_task = context.wait_for_external_event("RequestApproved")
  approval_rejected_task = context.wait_for_external_event("RequestRejected")
  final_status = None
  winner = yield context.task_any([approval_approved_task, approval_rejected_task, timeout_task])
  if winner == approval_approved_task or winner == approval_rejected_task:
    approved = winner == approval_approved_task and approval_approved_task.result == approval_code
    if not timeout_task.is_completed:
      timeout_task.cancel()
  if approved:
    final_status = yield context.call_activity("ApproveBlobFile", blob)
  return [approval_code , result, final_status]

main = df.Orchestrator.create(orchestrator_function)

The ApprovalTrigger which is a QueueTrigger function

import azure.functions as func
import azure.durable_functions as df


async def main(msg: func.QueueMessage, starter: str) -> None:
    logging.info('Python queue trigger function processed a queue item: %s',
                 msg.get_body().decode('utf-8'))
    client = df.DurableOrchestrationClient(starter)
    msg = msg.get_json()
    if msg["approval"] is True:
        event_name = "RequestApproved"
    else:
        event_name = "RequestRejected"
    await client.raise_event(instance_id=msg["instance_id"], event_name=event_name, event_data=msg["approval_code"])

And yes, in queue the double quotes are not being added. Its being added when the orchestrator receives the event.

🤔 Expected behavior
approval_approved_task.result must give out result '<approval_code>' not '"<approval_code>"'. For now we can use approval_approved_task.result.replace('\"','') == approval_code

Steps to reproduce

What Durable Functions patterns are you using, if any?
This is actually a sub orchestration function. The parent orchestration simply list all the files in the blob and runs this sub orchestration for each blob
Try raising any event from an external df activity
Its run locally. Will try to deploy to Azure soon and share the Orchestration instance ID with it.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority 2bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions