Support forward compatibility with definitions in bundled personalizers.#161
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 causesGetValueto return a (potentially unchanged/default) config instead ofnil. 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 settingfoundwhen 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, makingGetValuereturn a config when it should returnnil. Consider only settingfoundwhen 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
GetValueto 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.
sesposito
approved these changes
Jun 2, 2026
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.
No description provided.