fix: preserve V2 entity operation info for index zero#279
Open
YunchuWang wants to merge 1 commit into
Open
Conversation
When a framework-level exception occurs during V2 entity batch execution, resultsCount is 0 (zero individual results). The expression `resultsCount || operationInfos.length` evaluates to operationInfos.length because 0 is falsy in JavaScript, causing all operationInfos to be included despite there being no corresponding results. Replace with `resultsCount` directly, which is always a number from .length and needs no fallback. 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 falsy-zero bug in the V2 entity execution path so that when a framework-level error produces zero per-operation results, the worker includes zero operationInfos (instead of incorrectly including all infos). This aligns the response payload with the documented intent and avoids confusing/misleading routing metadata for DTS.
Changes:
- Fix
operationInfosslicing in_executeEntityInternal()by usingresultsCountdirectly (preserves the0case). - Add/extend Jest coverage around V2
operationInfosbehavior for success, not-found, multi-operation, and framework-error scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/durabletask-js/src/worker/task-hub-grpc-worker.ts | Fixes the `resultsCount |
| packages/durabletask-js/test/worker-entity.spec.ts | Adds tests validating V2 operationInfos count matches the number of results, including the framework-error zero-results regression case. |
Comment on lines
+437
to
+438
| it("should include zero operationInfos when entity run() throws on V2 execution", async () => { | ||
| // Arrange - entity whose run() throws |
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 #224