Skip to content

Validate JEXL targeting expressions against extracted field lists #14924

@data-sync-user

Description

@data-sync-user

Add unit tests that validate targeting config JEXL expressions only reference fields present in the relevant platform's targeting context.

Using the field lists from the parser (previous ticket) and the existing JEXL parsing in experiments/jexl_utils.py, add a test in targeting/tests/ that:

  • Parses each NimbusTargetingConfig's targeting JEXL expression to extract referenced identifiers
  • For each application the config applies to (from application_choice_names), checks that all referenced identifiers exist in that platform's targeting context field list (using the latest/unversioned version, since targeting configs are not version-scoped today)
  • Maintains a documented allowlist for known global/built-in JEXL identifiers that aren't targeting context fields (e.g., activeExperiments, activeRollouts, Nimbus SDK builtins)

Acceptance Criteria:

  • A test validates every targeting config's JEXL against the field list for its target application(s)
  • The test fails if a JEXL expression references a field not in the targeting context (and not in the allowlist)
  • The allowlist is documented and easy to maintain
  • The test runs as part of make check / CI
  • Validation uses the latest (unversioned) targeting context files

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions