Skip to content

Add ContinueAsNew search attribute tests for test server#2870

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

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

What was changed

Fixed the in-memory test server losing memo and search attributes across ContinueAsNew. The continued run now inherits both from the previous run by default, while still honoring explicit overrides, including explicit empty memo, and reflecting in-flight upsertMemo / upsertTypedSearchAttributes mutations.

Specifically:

  • StateMachines now populates memo and search attributes on the WorkflowExecutionContinuedAsNew event, falling back to the live workflow state when the command omits the field.
  • TestWorkflowService now copies memo from the WorkflowExecutionContinuedAsNew event onto the new run's start request. The search attributes path was already wired.

Why?

The in-memory test server's behavior diverged from the real Temporal service for ContinueAsNew runs that rely on inherited memo or search attributes. This made the test server unreliable for verifying memo/search-attribute-dependent workflow logic.

Checklist

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

  2. How was this tested:

  • Added six regression tests in ContinueAsNewTest covering inherit, override, upsert-then-inherit for memo and search attributes, upsert-null memo removal, and explicit empty memo override.
./gradlew :temporal-test-server:test --tests io.temporal.testserver.functional.ContinueAsNewTest
  1. Any docs updates needed?
    No. This is an internal test server behavior fix that aligns it with the real Temporal service; no public API 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

Hello @maciejdudko ,
Thank you for taking the time to review this, and for catching the issue.
I looked into it and confirmed the mismatch with the real server.

The original change made the test server inherit memos and search attributes on Continue-as-New, which the real server does not do (it simply copies command.Memo and command.SearchAttributes).
Search attributes only look preserved because the SDK carries them into the command, while memos are not carried over.

To address this, I made the following changes:

  • Removed all memo handling, so memos are now cleared, matching the real server.
  • Kept only the propagation of the command's search attributes, with no server-side inheritance.
  • Reduced the tests to the search-attribute cases: SDK carry-over and explicit override.

I confirmed that all tests pass both on the test server and on a real dev server (USE_DOCKER_SERVICE=true and 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
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