fix: strip system SAs from V1→CHASM schedule migration state#10911
Open
chaptersix wants to merge 2 commits into
Open
fix: strip system SAs from V1→CHASM schedule migration state#10911chaptersix wants to merge 2 commits into
chaptersix wants to merge 2 commits into
Conversation
bedfa22 to
6cd24f5
Compare
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
6cd24f5 to
2eec4a2
Compare
…migration-system-sa-leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a V1 scheduler workflow is migrated to CHASM, its raw search attributes (including system SAs like
TemporalNamespaceDivisionandTemporalSchedulePaused) were copied verbatim into the CHASM entity'sCustomSearchAttributesstore. 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:The log was benign —
TemporalNamespaceDivisionis overwritten with the archetype ID unconditionally afterward, andTemporalSchedulePausedis set fromSchedule.State.PausedbyScheduler.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 enterSchedulerMigrationState.SearchAttributesusingsadefs.IsReserved. This covers all current and future system SAs without needing a hardcoded list.Tests
migration_test.go):TestLegacyToCreateFromMigrationStateRequest_StripsSystemSearchAttributes— verifiesTemporalNamespaceDivisionandTemporalSchedulePausedare stripped while user-defined SAs are preserved.schedule_migration_test.go):TestScheduleMigrationV1ToV2_SearchAttributesAfterMigration— creates a paused V1 schedule (so the V1 workflow stamps both system SAs), migrates to CHASM, then asserts:TemporalSchedulePaused = trueis correctly queryable in visibility (framework manages it from live state)