Skip to content

Conversation

@awln-temporal
Copy link
Contributor

What changed?

Remove nil search attributes from history events / mutable state / chasm node

Why?

Search attributes can be explicitly set as null on the following events:

  • Workflow Start

  • Upsert Search Attributes

  • Continue-as-new

Starting a workflow or continuing a workflow as new with a nil search attribute records the {key: nil} mapping in mutable state and the history event.

Upserting search attributes erases any current search attribute value from persistence (mutable state and visibility record).

Upserting the search attribute as nil in the SDK retains the mapping in the WorkflowInfo as a {key: nil} mapping. On a continue-as-new event, SDK sends this mapping to Server, and the search attribute gets repopulated with the null search attribute in the history event and mutable state.

This last scenario can cause inconsistency between the expected search attributes and what is recorded in history. After upserting a nil search attribute, the mutable state and visibility record no longer shows this search attribute. But, once continuing as new, the search attribute reappears, leading to unexpected NDE if the search attribute is also deregistered.

CHASM change

This also removes nil search attributes from CHASM nodes on replacement. This mirrors the change to Workflow History Events and Mutable State.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

@awln-temporal awln-temporal requested review from a team as code owners January 21, 2026 00:42
@awln-temporal awln-temporal requested a review from yycptt January 21, 2026 00:42
@awln-temporal awln-temporal force-pushed the remove-nil-search-attributes branch from 4d9aa43 to f71cea1 Compare January 21, 2026 19:23
s.Nil(s.visibility.CustomSearchAttributes(s.mockContext))

// Test that nil values are filtered out during replace.
s.visibility.ReplaceCustomSearchAttributes(
Copy link
Contributor

Choose a reason for hiding this comment

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

Test NewVisibilityWithData with nil values as well please

// Reuses MergeMapOfPayload which already handles nil payload filtering.
func FilterNilSearchAttributes(sa *commonpb.SearchAttributes) *commonpb.SearchAttributes {
if sa == nil || len(sa.GetIndexedFields()) == 0 {
return sa
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on your comments above, this should be return nil.

OriginalExecutionRunId: originalRunID,
Memo: req.Memo,
SearchAttributes: req.SearchAttributes,
SearchAttributes: payload.FilterNilSearchAttributes(req.SearchAttributes),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this is a safe change.
cc: @yycptt

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.

3 participants