Skip to content

Support forward compatibility with definitions in bundled personalizers.#161

Merged
novabyte merged 1 commit into
mainfrom
cdm-definition-forwardcompat
Jun 3, 2026
Merged

Support forward compatibility with definitions in bundled personalizers.#161
novabyte merged 1 commit into
mainfrom
cdm-definition-forwardcompat

Conversation

@novabyte

@novabyte novabyte commented Jun 2, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR relaxes JSON decoding strictness in the built-in Storage and Satori personalizers to allow forward compatibility when personalized definitions contain newer/unknown fields, and documents the change in the changelog.

Changes:

  • Remove decoder.DisallowUnknownFields() when decoding Storage personalizer values into system configs.
  • Remove decoder.DisallowUnknownFields() when decoding Satori flags and Satori live event values into system configs.
  • Add an [Unreleased] changelog entry noting forward-compatibility support.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
personalizer_storage.go Makes Storage personalizer config decoding tolerant of unknown JSON fields.
personalizer_satori.go Makes Satori flag/live-event config decoding tolerant of unknown JSON fields (but requires an additional guard to avoid false-positive “found” merges for live events).
CHANGELOG.md Documents the forward-compatibility behavior change under [Unreleased].
Comments suppressed due to low confidence (3)

personalizer_satori.go:485

  • With DisallowUnknownFields removed, decoding a live event JSON object with only unknown keys will now succeed and set found = true, which causes GetValue to return a (potentially unchanged/default) config instead of nil. This breaks the existing behavior where unrelated live events were skipped via a decode error (see the comment about events intended for a different purpose). Consider only setting found when the decode actually changes the config (e.g., compare a pre/post marshal), or otherwise filter out no-op merges.
				for _, liveEvent := range liveEventsList.LiveEvents {
					decoder := json.NewDecoder(strings.NewReader(liveEvent.Value))
					if err := decoder.Decode(config); err != nil {
						// The live event may be intended for a different purpose, do not log or return an error here.
						continue
					}
					found = true
				}

personalizer_satori.go:576

  • Same issue as the non-cached path: with DisallowUnknownFields removed, unrelated live events can decode successfully as a no-op (unknown keys ignored) and still set found = true, making GetValue return a config when it should return nil. Consider only setting found when the live event decode actually changes the config.
			for _, liveEvent := range liveEventsList.LiveEvents {
				decoder := json.NewDecoder(strings.NewReader(liveEvent.Value))
				if err := decoder.Decode(config); err != nil {
					// The live event may be intended for a different purpose, do not log or return an error here.
					continue
				}
				found = true
			}

personalizer_satori.go:459

  • This change makes Satori flag JSON decoding tolerant of unknown fields (forward compatibility), but there are no tests asserting that unknown fields no longer cause GetValue to error and that only recognized fields affect the returned config. Adding a focused unit test would help prevent regressions (including the live-event filtering behavior).
			config = system.GetConfig()
			decoder := json.NewDecoder(strings.NewReader(flagList.Flags[0].Value))
			if err := decoder.Decode(config); err != nil {
				logger.WithField("userID", userID).WithField("error", err.Error()).Error("error merging Satori flag value")
				return nil, err
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@novabyte novabyte merged commit 9ea1c6e into main Jun 3, 2026
3 checks passed
@novabyte novabyte deleted the cdm-definition-forwardcompat branch June 3, 2026 09:18
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