[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#401
Open
jaeopt wants to merge 5 commits into
Open
[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#401jaeopt wants to merge 5 commits into
jaeopt wants to merge 5 commits into
Conversation
…ing per updated spec Per updated FSSDK-12813 spec, campaign_id and entity_id now accept any non-empty string (numeric or opaque, e.g. "default-12345", "layer_abc"). The fallback to experiment_id fires ONLY when the value is empty string, nil, or missing. variation_id retains the stricter numeric-string-only contract — empty/whitespace/non-numeric values still normalize to nil. Non-string types remain out of scope per spec. Changes: - EventIdValidator: introduce non_empty_string? predicate; use it for campaign_id normalization while keeping numeric_string? for variation_id. - Unit tests: add non_empty_string? coverage; update normalize_campaign_id tests so opaque/whitespace inputs pass through (per relaxed FR-001). - EventFactory integration tests: flip non-numeric/whitespace campaign_id cases from fallback assertions to passthrough assertions. - project_spec.rb: update a pre-existing wire-payload assertion to expect variation_id: nil (was '') per the variation_id normalization.
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 three ID fields on outgoing decision events —
decisions[].campaign_id,decisions[].variation_id, and impressionevents[].entity_id— so the wire payload is byte-equivalent across SDKs for every decision type (experiment, feature test, rollout, holdout). The normalization path is silent and never drops, defers, or fails event dispatch.Per the updated FSSDK-12813 spec,
campaign_idandentity_idaccept any non-empty string (numeric or opaque, e.g."default-12345","layer_abc"); the fallback toexperiment_idfires only when the value is empty string,nil, or missing.variation_idkeeps the stricter numeric-string-only contract — empty/whitespace/non-numeric values normalize tonil. Non-string types are out of scope.Changes
Helpers::EventIdValidatormodule with two predicates:non_empty_string?(used forcampaign_idandentity_id, accepts any non-empty string including opaque IDs) andnumeric_string?(used forvariation_id, requires decimal digits only). The normalization helpers apply the spec's substitution rules:campaign_idfalls back toexperiment_idonly when empty/nil; invalidvariation_idbecomesnil.EventFactory#create_impression_event_visitorso the rule applies uniformly to experiment, feature test, rollout, and holdout decisions with no per-type branching.events[].entity_idreuses the same normalizedcampaign_idbyte-for-byte (impression-only; conversion event entity_id is unchanged).campaign_idand nil-fallback forvariation_id) and integration coverage on the EventFactory wire payload covering nil, empty, whitespace, non-string, non-numeric-placeholder, and opaque-prefixed (e.g.default-12345) inputs, plus a holdout scenario.spec/project_spec.rbto expectvariation_id: nil(was'') for the rollout-no-match path, per the variation_id normalization rule (FR-011).Jira Ticket
FSSDK-12813