Skip to content

Add ContinueAsNew search attribute tests for test server#2870

Closed
baekgyu-kim wants to merge 1 commit into
temporalio:masterfrom
baekgyu-kim:2655
Closed

Add ContinueAsNew search attribute tests for test server#2870
baekgyu-kim wants to merge 1 commit into
temporalio:masterfrom
baekgyu-kim:2655

Conversation

@baekgyu-kim
Copy link
Copy Markdown

@baekgyu-kim baekgyu-kim commented May 5, 2026

What was changed

Added regression test coverage for search-attribute behavior on ContinueAsNew in the in-memory test server.
No production code is changed.

The correct behavior already exists on master: on ContinueAsNew the server propagates the command's search attributes to the new run, and the SDK carries the previous run's search attributes into the command when none are specified.
This PR adds the tests that were missing to lock that behavior in.

Note: an earlier version of this PR also made the test server inherit memo and search attributes from the previous run.
That does not match the real Temporal service, which builds the new run's StartWorkflowExecutionRequest directly from the command (Memo: command.Memo, SearchAttributes: command.SearchAttributes) and inherits neither.
Search attributes only survive because the SDK carries them into the command, while memos are not carried over and are effectively cleared. Those production changes were removed.

Why?

To verify that ContinueAsNew carries search attributes in the test server, matching the real Temporal service, and to guard against regressions. Memo is intentionally not preserved, consistent with the real service.

Checklist

  1. Closes Testing server continue-as-new doesn't carry search attributes #2655.

  2. How was this tested:

  • Added two regression tests in ContinueAsNewTest: search-attribute carry-over when none are specified, and explicit override.
  • Verified on both the in-process test server and a real dev server.
./gradlew :temporal-test-server:test --tests io.temporal.testserver.functional.ContinueAsNewTest
  1. Any docs updates needed?
    No. This is test-only coverage for existing test server behavior; no public API or behavior change.

Copy link
Copy Markdown
Contributor

@maciejdudko maciejdudko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @baekgyu-kim, thank you for your contribution. Unfortunately there was a mistake in the referenced issue - the real server only preserves Search Attributes on Continue-as-New; Memos are cleared. Which means the PR in its current form does not match the real server behavior. Please remove the changes to Memo handling and only keep the changes to Search Attributes handling. Make sure all tests pass both when run on test server and on real server. You can make the tests use a local dev server by setting environment variables USE_DOCKER_SERVICE=true and USE_EXTERNAL_SERVICE=true. You can start a local dev server by using Temporal CLI: temporal server start-dev --namespace UnitTest --search-attribute CustomKeywordField=Keyword

@baekgyu-kim
Copy link
Copy Markdown
Author

baekgyu-kim commented May 20, 2026

Hello @maciejdudko ,
Thank you for taking the time to review this, and for catching the issue.

I checked the server code and confirmed the mismatch.
On Continue-as-New, the server builds the new run's StartWorkflowExecutionRequest directly from the command (Memo: command.Memo, SearchAttributes: command.SearchAttributes), inheriting nothing from the previous run. (mutable_state_impl.go)
The difference is on the SDK side. It carries the previous run's search attributes into the command, but not the memo.
So search attributes survive, while the memo arrives empty and is effectively cleared.

The correct search-attribute propagation already existed on master.
So I left the existing code unchanged and added test coverage for search-attribute behavior on Continue-as-New: SDK carry-over when none are specified, and explicit override.

I verified that the ContinueAsNewTest cases pass on both the in-process test server and a real dev server (USE_DOCKER_SERVICE=true, USE_EXTERNAL_SERVICE=true).

Whenever you have a moment, I would appreciate it if you could take another look.
Thank you again for your guidance.

@baekgyu-kim baekgyu-kim changed the title Fix ContinueAsNew dropping memo and search attributes in test server Fix ContinueAsNew dropping search attributes in test server May 20, 2026
@baekgyu-kim baekgyu-kim changed the title Fix ContinueAsNew dropping search attributes in test server Add ContinueAsNew search attribute tests for test server May 20, 2026
@baekgyu-kim baekgyu-kim requested a review from maciejdudko May 20, 2026 23:33
@maciejdudko
Copy link
Copy Markdown
Contributor

Apologies again. After looking more into both test server and real server implementation, it looks like the server doesn't preserve Search Attributes across CaN either. We have client-side logic in the SDK to automatically transfer SA when none are set in the request (SyncWorkflowContext.java), and this gives the illusion it's the server doing this work.

The bottom line is - the test server preserves neither Memos nor Search Attributes, this behavior matches the real server, the tests in this PR exercise SDK behavior rather than test server behavior, and issue #2655 was invalid to begin with.

I'm sorry for wasting your time on this. Still, I really appreciate your contribution and you're welcome to look at other open issues and submit more PRs.

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.

Testing server continue-as-new doesn't carry search attributes

2 participants