Skip to content

fix: strip system SAs from V1→CHASM schedule migration state#10911

Open
chaptersix wants to merge 2 commits into
temporalio:mainfrom
chaptersix:fix/chasm-schedule-migration-system-sa-leak
Open

fix: strip system SAs from V1→CHASM schedule migration state#10911
chaptersix wants to merge 2 commits into
temporalio:mainfrom
chaptersix:fix/chasm-schedule-migration-system-sa-leak

Conversation

@chaptersix

Copy link
Copy Markdown
Contributor

Summary

When a V1 scheduler workflow is migrated to CHASM, its raw search attributes (including system SAs like TemporalNamespaceDivision and TemporalSchedulePaused) were copied verbatim into the CHASM entity's CustomSearchAttributes store. The visibility task executor then iterated these and routed each one through the custom SA mapper. System SAs have no per-namespace mapping, so the mapper returned an error and emitted a spurious warn-level log:

"Failed to get field name for alias, ignoring search attribute"
alias="TemporalNamespaceDivision"
error="Namespace <ns> has no mapping defined for search attribute TemporalNamespaceDivision"

The log was benign — TemporalNamespaceDivision is overwritten with the archetype ID unconditionally afterward, and TemporalSchedulePaused is set from Schedule.State.Paused by Scheduler.SearchAttributes(). But system SAs have no business being in the custom SA store.

Fix

In LegacyToCreateFromMigrationStateRequest (chasm/lib/scheduler/migration/migration.go), filter out reserved/system SAs before they enter SchedulerMigrationState.SearchAttributes using sadefs.IsReserved. This covers all current and future system SAs without needing a hardcoded list.

Tests

  • Unit test (migration_test.go): TestLegacyToCreateFromMigrationStateRequest_StripsSystemSearchAttributes — verifies TemporalNamespaceDivision and TemporalSchedulePaused are stripped while user-defined SAs are preserved.
  • Functional test (schedule_migration_test.go): TestScheduleMigrationV1ToV2_SearchAttributesAfterMigration — creates a paused V1 schedule (so the V1 workflow stamps both system SAs), migrates to CHASM, then asserts:
    • Custom SAs survive migration
    • System SAs are absent from the CHASM entity's custom SA store
    • TemporalSchedulePaused = true is correctly queryable in visibility (framework manages it from live state)

@chaptersix chaptersix force-pushed the fix/chasm-schedule-migration-system-sa-leak branch 2 times, most recently from bedfa22 to 6cd24f5 Compare July 2, 2026 22:40
When a V1 scheduler workflow is migrated to CHASM, its raw search
attributes (including system SAs like TemporalNamespaceDivision
and TemporalSchedulePaused) were copied verbatim into the CHASM
entity's CustomSearchAttributes store. The visibility task executor
then iterated these and routed each one through the custom SA mapper.
System SAs have no per-namespace mapping, so the mapper returned an
error and emitted a spurious warn-level log:

  "Failed to get field name for alias, ignoring search attribute"
  alias="TemporalNamespaceDivision"
  error="Namespace <ns> has no mapping defined for search attribute TemporalNamespaceDivision"

The log was benign — TemporalNamespaceDivision is overwritten with
the archetype ID unconditionally afterward, and TemporalSchedulePaused
is set from Schedule.State.Paused by Scheduler.SearchAttributes(). But
system SAs have no business being in the custom SA store.

Fix: filter out reserved/system SAs in LegacyToCreateFromMigrationStateRequest
before they enter SchedulerMigrationState.SearchAttributes using
sadefs.IsReserved. This covers all current and future system SAs
without needing a hardcoded list.

Also adds:
- unit test (table-driven) for the SA stripping logic
- functional test verifying system SAs don't leak into the custom SA
  store after migration and that framework-managed SAs reflect correct
  schedule state
@chaptersix chaptersix force-pushed the fix/chasm-schedule-migration-system-sa-leak branch from 6cd24f5 to 2eec4a2 Compare July 2, 2026 22:57
@chaptersix chaptersix marked this pull request as ready for review July 2, 2026 23:36
@chaptersix chaptersix requested a review from a team as a code owner July 2, 2026 23:36
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.

1 participant