fix: BatchResult completion reason logic #286
Open
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.
Description of changes:
Fix BatchResult.from_items() to match JavaScript SDK behavior. The previous implementation incorrectly checked conditions in the wrong order, causing incorrect completion reasons for concurrent operations with failure tolerance configurations.
The checkpointed completion reason is preserved during replay, so existing executions are unaffected. Code with conditional logic based on completion_reason might see different values after this update.
Example: With 3 items (1 success, 2 failures) and tolerated_failure_count=1:
Changes:
This ensures tolerance checks take precedence over success criteria, preventing operations from incorrectly reporting ALL_COMPLETED when failure tolerance has been exceeded.
new behaviour
Different
completion_reasonvalues for map/parallel operations in these scenarios:FAILURE_TOLERANCE_EXCEEDED(previouslyALL_COMPLETED)FAILURE_TOLERANCE_EXCEEDED(previouslyALL_COMPLETED)FAILURE_TOLERANCE_EXCEEDED(previouslyALL_COMPLETED)FAILURE_TOLERANCE_EXCEEDED(previouslyMIN_SUCCESSFUL_REACHED)reference logic
https://github.com/aws/aws-durable-execution-sdk-js/blob/main/packages/aws-durable-execution-sdk-js/src/handlers/concurrent-execution-handler/concurrent-execution-handler.ts#L41-L75
Issue #, if available:
closes #280
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.