fix: validate empty external event names#276
Open
YunchuWang wants to merge 1 commit into
Open
Conversation
…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>
Contributor
There was a problem hiding this comment.
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 emptyinstanceIdand emptyeventName. - 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #228