Skip to content

[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#518

Merged
FarhanAnjum-opti merged 7 commits into
masterfrom
ai/jaeopt/FSSDK-12813-holdout-event
Jul 2, 2026
Merged

[AI-FSSDK] [FSSDK-12813] Normalize decision event campaign_id, variation_id, and entity_id#518
FarhanAnjum-opti merged 7 commits into
masterfrom
ai/jaeopt/FSSDK-12813-holdout-event

Conversation

@jaeopt

@jaeopt jaeopt commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Normalize three decision-event ID fields uniformly across every decision type (experiment, feature test, rollout, holdout) in the event-builder layer so the wire payload is byte-equivalent across SDKs for the same input. decisions[].campaign_id and impression events[].entity_id fall back to experiment_id only when the value is empty string or None — any non-empty string (numeric like "12345" or opaque like "default-12345", "layer_abc") passes through unchanged. decisions[].variation_id retains the strict numeric-string contract and falls back to None for empty/whitespace/non-numeric input. The path never logs, raises, or drops dispatch.

Changes

  • Added optimizely/event/event_id_normalizer.py with pure helpers (is_non_empty_string, is_numeric_id_string, normalize_campaign_id, normalize_variation_id). normalize_campaign_id accepts any non-empty string and falls back to experiment_id only on empty/None; normalize_variation_id keeps the strict decimal-digit contract and returns None otherwise.
  • Wired the normalizer into event_factory.py (current) and event_builder.py (legacy) on the single impression path so both producers emit identical output.
  • Reused the normalized campaign_id for events[].entity_id so the two fields are byte-equivalent by construction. Typed Decision.variation_id as Optional[str] so invalid inputs serialize as JSON null.
  • Audited existing event-builder tests per FR-011 — happy-path fixtures already use numeric IDs; integration tests updated to assert opaque-string passthrough for campaign_id / entity_id and null normalization for variation_id.

Jira Ticket

FSSDK-12813

@FarhanAnjum-opti FarhanAnjum-opti 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.

LGTM

@FarhanAnjum-opti FarhanAnjum-opti merged commit a1e0da8 into master Jul 2, 2026
14 of 16 checks passed
@FarhanAnjum-opti FarhanAnjum-opti deleted the ai/jaeopt/FSSDK-12813-holdout-event branch July 2, 2026 15:35
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.

2 participants