Skip to content

fix: validate empty external event names#276

Open
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/empty-event-name-validation
Open

fix: validate empty external event names#276
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/empty-event-name-validation

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #228

…and sendEvent()

waitForExternalEvent() and sendEvent() in RuntimeOrchestrationContext
did not validate that event names are non-empty. Passing an empty string
to waitForExternalEvent() creates a task that can never complete because
handleEventRaised uses a truthy check that treats '' as falsy, skipping
the pending task lookup entirely. Similarly, sendEvent() accepted empty
instanceId and eventName without error.

This adds validation consistent with the client-side
raiseOrchestrationEvent() method, which already validates event names.

Fixes #228

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a runtime correctness gap in the Durable Task JavaScript SDK orchestration context by rejecting empty external event names early, preventing orchestrations from creating unmatchable pending event waits (and therefore hanging indefinitely).

Changes:

  • Added input validation to RuntimeOrchestrationContext.waitForExternalEvent() to throw on empty event names.
  • Added input validation to RuntimeOrchestrationContext.sendEvent() to throw on empty instanceId and empty eventName.
  • Added unit tests asserting orchestrations fail (rather than hang or emit invalid actions) when these invalid inputs are used.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Adds runtime guards that reject empty event names (and empty target instance IDs for sendEvent) to prevent creation of uncompletable waits/actions.
packages/durabletask-js/test/orchestration_executor.spec.ts Adds a regression test ensuring waitForExternalEvent("") fails the orchestration rather than producing a stuck pending wait.
packages/durabletask-js/test/orchestration_context_methods.spec.ts Adds regression tests ensuring sendEvent("", ...) and sendEvent(..., "", ...) fail the orchestration rather than producing invalid actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: waitForExternalEvent() and sendEvent() accept empty event names, creating uncompletable tasks

3 participants