-
Notifications
You must be signed in to change notification settings - Fork 11
[copilot-finds] Bug: InMemoryOrchestrationBackend crashes on SENDENTITYMESSAGE and TERMINATEORCHESTRATION action types #209
Description
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
- Add a
SENDENTITYMESSAGEcase (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. - Add a
TERMINATEORCHESTRATIONcase (case 7) that extracts the target instance ID from the action and delegates to the existingterminate()method. - 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.