Skip to content

[copilot-finds] Bug: InMemoryOrchestrationBackend does not propagate parent instance info for sub-orchestrations #243

@github-actions

Description

@github-actions

Problem

InMemoryOrchestrationBackend.createInstance() does not accept or forward parent instance information to the ExecutionStartedEvent it creates. When processCreateSubOrchestrationAction() creates a sub-orchestration, it calls createInstance(subInstanceId, name, input) without passing the parent orchestration's identity.

This causes ctx.parent to always be undefined for sub-orchestrations in the test environment, even though the real sidecar populates this field via the ParentInstanceInfo on the ExecutionStartedEvent.

Affected files:

  • packages/durabletask-js/src/testing/in-memory-backend.tscreateInstance() (line 80) and processCreateSubOrchestrationAction() (line 567)

Root Cause

createInstance() has no parentInstance parameter, so it always calls newExecutionStartedEvent(name, instanceId, input) without the fourth parentInstance argument. The helper function already supports this parameter — it just was never passed from the in-memory backend.

processCreateSubOrchestrationAction() has access to the parent instance's name, instanceId, and the taskId (which serves as taskScheduledId), but does not forward them.

Proposed Fix

  1. Add an optional parentInstance parameter to createInstance()
  2. Forward it to newExecutionStartedEvent()
  3. Pass parent info from processCreateSubOrchestrationAction() when creating sub-orchestrations

Impact

Severity: Medium — Any test that checks ctx.parent in a sub-orchestration will get undefined instead of the correct parent info. This creates a behavioral gap between the test environment and production, which could cause:

  • Tests that verify parent-child relationships to falsely fail
  • Tests that rely on ctx.parent being set to silently skip logic that would run in production

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions