[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#455
Open
jaeopt wants to merge 4 commits into
Open
[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#455jaeopt wants to merge 4 commits into
jaeopt wants to merge 4 commits into
Conversation
…ing per updated spec
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
Normalize the
campaign_id,variation_id, andentity_idfields on outgoing decision events uniformly across every decision type (experiment, feature test, rollout, holdout) so the SDK emits cross-SDK byte-equivalent wire output. Per the updated FSSDK-12813 spec:decisions[].campaign_idand impressionevents[].entity_idrequire a non-empty string (any character content — IDs may be opaque, e.g."default-12345","layer_abc") and fall back toexperiment_idonly when empty;decisions[].variation_idretains a strict numeric-string contract and becomes JSONnullfor empty / non-numeric values. The path never logs, errors, or blocks event dispatch.Changes
pkg/event/event_id_normalizer.gowith pure helpers:IsNonEmptyString— relaxed predicate forcampaign_id/entity_id.IsNumericIDString— strict predicate, still used forvariation_id.NormalizeCampaignID(campaignID, experimentID)— returnscampaignIDwhen non-empty (opaque values allowed); otherwise falls back toexperimentID.NormalizeVariationID(variationID) *string— returns a pointer whenvariationIDis a numeric string; otherwisenilso the field serializes as JSONnull.pkg/event/factory.go—createImpressionEventnormalizes fromexperiment.LayerID(falling back toexperiment.IDonly when LayerID is empty, e.g. holdouts with no layer) and reuses the same value forEntityID.createImpressionVisitorre-applies normalization as defense-in-depth so the two fields cannot drift. Conversion path is untouched.Decision.VariationIDto*stringso empty / non-numeric upstream values marshal to JSONnull, matching the cross-SDK contract and the existing nullable-field convention used byDecisionMetadata.CmabUUID.campaign_id/entity_idcontract: addedTestIsNonEmptyString,TestNormalizeCampaignID_PassesThroughOpaqueCampaignID,TestNormalizeCampaignID_PassesThroughHoldoutPlaceholder,TestNormalizeCampaignID_PassesThroughWhitespaceCampaign, andTestImpressionEvent_PassesThroughOpaqueLayerIDto assert that non-numeric / opaque values now pass through unchanged. Empty-LayerID holdout fallback assertions and the strictvariation_idtests are unchanged.Notes
Decision.VariationIDchanging fromstringto*stringis a Go-source-level breaking change for any downstream consumer that constructsevent.Decisionliterals directly (no such usages exist in this repo outside the event package itself). The on-the-wire JSON contract is unchanged in shape.string); the spec relaxation is therefore purely a predicate change.Jira Ticket
FSSDK-12813