Skip to content

[copilot-finds] Bug: InMemoryOrchestrationBackend crashes on SENDENTITYMESSAGE and TERMINATEORCHESTRATION action types #209

@github-actions

Description

@github-actions

Problem

The InMemoryOrchestrationBackend.processAction() method in packages/durabletask-js/src/testing/in-memory-backend.ts handles orchestrator actions via a switch statement on OrchestratoractiontypeCase. It only handles cases 2–6 (SCHEDULETASK, CREATESUBORCHESTRATION, CREATETIMER, SENDEVENT, COMPLETEORCHESTRATION), but the protobuf enum also defines:

  • Case 7: TERMINATEORCHESTRATION
  • Case 8: SENDENTITYMESSAGE

The default case throws an Error, so any orchestration that uses entity signals (ctx.entities.signalEntity()) or terminates another orchestration from within an orchestrator crashes with "Unexpected action type: 8" (or 7) when run against the in-memory testing backend.

Root Cause

The in-memory backend was implemented before entity support was added to the orchestration context. When entity features (signalEntity, callEntity, lockEntities) and terminateOrchestration actions were introduced, the corresponding action type handling was not added to the backend's processAction() switch statement.

Proposed Fix

  1. Add a SENDENTITYMESSAGE case (case 8) as a no-op — entity signals are fire-and-forget; the in-memory backend does not simulate entity workers, so silently accepting the action is the correct behavior.
  2. Add a TERMINATEORCHESTRATION case (case 7) that extracts the target instance ID from the action and delegates to the existing terminate() method.
  3. Add unit tests verifying orchestrations that signal entities complete successfully when using the in-memory backend.

Impact

Severity: Medium — This prevents testing any orchestration that uses entity features against the in-memory backend. Users writing unit tests for orchestrations that signal entities would encounter a crash. The workaround is to avoid entity operations in in-memory backend tests, but this limits the testing surface.

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