Repository navigation
Fix Nexus callback ref encoding in test server - #3201
Open
allanj-nflx wants to merge 1 commit into
Open
allanj-nflx wants to merge 1 commit into
allanj-nflx wants to merge 1 commit into
Conversation
The test server stored the binary NexusOperationRef in the operation-reference callback header by decoding it as UTF-8. The scheduled event ID is written as eight raw bytes, so any byte of 0x80 or above was replaced with U+FFFD. The ref then decoded to a different event ID, the lookup failed with NOT_FOUND, and the completion callback was dropped without an error. The caller's operation stayed started until its schedule-to-close timeout. Most scheduled event IDs above 127 were affected. Base64-encode the ref in the header instead. Fixes temporalio#3200 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
1 similar comment
|
|
This branch has not been deployed
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.
What changed?
NexusOperationRefit puts in theoperation-referencecallback header, and decodes it the same way when the handler workflow completes.NexusOperationRefhas newtoHeaderValue()andfromHeaderValue(String)helpers for this, so the encode and decode code stays in one place.WorkflowIdConflictPolicyTestattaches a callback built by hand, so I updated it to use the new encoding.AsyncWorkflowOperationLongHistoryTest. Its caller workflow records 150 side-effect markers before it calls aWorkflowRunOperation, so the operation is scheduled at event 155. The test asserts that the operation's result arrives.Fixedin the changelog.Why?
Fixes #3200.
NexusOperationRef.toBytes()is binary:writeUTFlength prefixes, thenwriteLong(scheduledEventId). The test server turned it into a header string withByteString.toStringUtf8()and read it back withString.getBytes(). A byte of0x80or above isn't valid UTF-8 on its own, so it was replaced with U+FFFD, and the ref decoded to a different scheduled event ID (every ID from 128 to 255 decodes as 239). The lookup then failed withNOT_FOUND, which the completion callback loop deliberately ignores, so the completion was dropped without an error. The caller's operation stayedSTARTEDuntil its schedule-to-close timeout. Base64 output is ASCII, so the round trip is lossless.The change only affects the in-memory test server. Real servers build their own callback tokens.
How was this tested?
AsyncWorkflowOperationLongHistoryTestfails. The caller's history showsNEXUS_OPERATION_TIMED_OUT(TIMEOUT_TYPE_SCHEDULE_TO_CLOSE) for scheduled event 155 even though the handler workflow completed, and the test times out after 10 seconds.AsyncWorkflowOperationLongHistoryTestpasses.AsyncWorkflowOperationTest,WorkflowIdConflictPolicyTestandNexusWorkflowTest(test server module) pass too../gradlew :temporal-test-server:spotlessApply :temporal-sdk:spotlessApplypasses, and so doesspotlessCheck. I ran on Java 21 against the built-in test server. I didn't run the full suite.Breaking changes?
None. The header value is opaque to SDKs and handlers, and only the test server writes and reads it.
Server PR
Not required.
🤖 Generated with Claude Code