Skip to content

Fix Nexus callback ref encoding in test server - #3201

Open
allanj-nflx wants to merge 1 commit into
temporalio:mainfrom
allanj-nflx:fix-test-server-nexus-callback-ref
Open

allanj-nflx wants to merge 1 commit into
temporalio:mainfrom
allanj-nflx:fix-test-server-nexus-callback-ref

Conversation

@allanj-nflx

Copy link
Copy Markdown

What changed?

  • The test server now Base64-encodes the NexusOperationRef it puts in the operation-reference callback header, and decodes it the same way when the handler workflow completes. NexusOperationRef has new toHeaderValue() and fromHeaderValue(String) helpers for this, so the encode and decode code stays in one place.
  • WorkflowIdConflictPolicyTest attaches a callback built by hand, so I updated it to use the new encoding.
  • I added AsyncWorkflowOperationLongHistoryTest. Its caller workflow records 150 side-effect markers before it calls a WorkflowRunOperation, so the operation is scheduled at event 155. The test asserts that the operation's result arrives.
  • I added an entry under Fixed in the changelog.

Why?

Fixes #3200.

NexusOperationRef.toBytes() is binary: writeUTF length prefixes, then writeLong(scheduledEventId). The test server turned it into a header string with ByteString.toStringUtf8() and read it back with String.getBytes(). A byte of 0x80 or 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 with NOT_FOUND, which the completion callback loop deliberately ignores, so the completion was dropped without an error. The caller's operation stayed STARTED until 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?

  • Before the fix, AsyncWorkflowOperationLongHistoryTest fails. The caller's history shows NEXUS_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.
  • After the fix, AsyncWorkflowOperationLongHistoryTest passes. AsyncWorkflowOperationTest, WorkflowIdConflictPolicyTest and NexusWorkflowTest (test server module) pass too.
  • ./gradlew :temporal-test-server:spotlessApply :temporal-sdk:spotlessApply passes, and so does spotlessCheck. 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

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>
@allanj-nflx
allanj-nflx requested a review from a team as a code owner November 10, 2026 22:21
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
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.

Test server drops async Nexus operation completion when the scheduled event ID is above 127

2 participants