:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(flags): accept and evaluate string, number and object rules v2 values (#107733)
Anders61701180279c
diff --git a/docs/internal/feature-flags/api-writes.md b/docs/internal/feature-flags/api-writes.mdindex 61dec8b157e4..711c97c22e4c 100644--- a/docs/internal/feature-flags/api-writes.md+++ b/docs/internal/feature-flags/api-writes.md@@ -77,6 +77,7 @@ A stored version 2 row that is not remote-configured and carries no encrypted pa- A new row is created disabled with server-owned rule IDs and seeds; the request document is resolved against an empty stored document and validated strictly before it is persisted exactly. No v1 row is converted.- A supplied `filters` object replaces the whole configuration. There is no top-level merge, no rule merge by index, no filling of omitted fields from the stored document, and no v1 normalization. `{}`, `null`, a list, and an incomplete object are invalid; a complete document with `rules: []` is valid.+- `return_type` is `boolean`, `string`, `number` or `object` and cannot change after creation. `default_value` is null or the declared type; every rule `value` is the declared type. Strings are non-empty and not `$false`, the event-storage sentinel that v1 also reserves as a variant key; numbers lie within ±(2^53 − 1); objects nest at most 20 object or array levels with numbers in the same range.- Rule IDs and percentage-rollout seeds are server-owned and identify rules rather than list positions. An echoed ID keeps its seed through reordering and unrelated edits; a rule that omits its ID is new and receives fresh identity. An unknown ID, an ID used twice, a client-chosen seed, and a changed seed are all rejected.- `FeatureFlag.version` is required on every update and must equal the locked row's value. Unlike v1 there is no `original_flag` merge: a stale token is a conflict even when no individual field clashes. The token applies to disabling and deleting too.- Identity resolution, validation and the enable check run against the locked row inside the existing update transaction. A stored document with an unsupported shape or semantics is rejected rather than replaced or enabled. Configuration and metadata byte limits apply to a replacement, so an oversized stored document can be edited back under a lowered limit; enabling requires the stored document to fit the current limits.@@ -87,3 +88,5 @@ A stored version 2 row that is not remote-configured and carries no encrypted pa- Each accepted write saves once, increments `version` once, runs the existing cache invalidation and produces one activity log entry through the existing receiver. The entry carries the generic field diff; canonical version 2 summaries and version-history reconstruction are later work.Rollback turns both flags off. Existing version 2 rows stay readable, disableable and deletable; there is no data conversion, and v1-to-v2 dependency protection is not removed.++A flags service that predates string, number and object values fails such a flag: the flag gets an error entry and the whole `/flags` response sets `errorsWhileComputingFlags`, so posthog-js merges it into its cached flags instead of replacing them. Deploy the flags service that evaluates these types before an admitted project creates one. Turning the writer flags off stops new ones but leaves enabled ones served; disable every enabled string, number and object flag before reverting the flags service.diff --git a/products/feature_flags/backend/api/test/test_feature_flag_config_v2_lifecycle.py b/products/feature_flags/backend/api/test/test_feature_flag_config_v2_lifecycle.pyindex 83898f319549..01bbc68632fd 100644--- a/products/feature_flags/backend/api/test/test_feature_flag_config_v2_lifecycle.py+++ b/products/feature_flags/backend/api/test/test_feature_flag_config_v2_lifecycle.py@@ -17,6 +17,7 @@ from products.approvals.backend.serializers import ApprovalPolicySerializerfrom products.feature_flags.backend.api.feature_flag import FeatureFlagSerializerfrom products.feature_flags.backend.api.test.test_feature_flag_config_v2_updates import (AdmittedV2TestCase,+ JsonValue,V2UpdateTestCase,admit_v2,config,@@ -29,6 +30,13 @@ from products.feature_flags.backend.local_evaluation import _get_flags_response_from products.feature_flags.backend.models import FeatureFlag+def nested_list(levels: int) -> JsonValue:+ value: JsonValue = 1+ for _ in range(levels):+ value = [value]+ return value++class TestV2SafetyWritesNeedNoAdmission(V2UpdateTestCase):"""Disabling and soft-deleting are the pilot's incident controls: they work with both writer flags off."""@@ -121,6 +129,48 @@ class TestAdmittedV2Creation(AdmittedV2TestCase):(entry,) = self.activity(flag)assert entry.activity == "created"+ @parameterized.expand(+ [+ ("string", "compact", "standard"),+ ("number", -2.5, 0),+ ("object", {"layout": "compact", "options": [1, True, None]}, {}),+ ]+ )+ def test_typed_documents_are_created_and_round_trip(+ self, return_type: str, value: JsonValue, default: JsonValue+ ) -> None:+ submitted = config(+ targeted(rule_id=None, value=value), rollout(rule_id=None, seed=None, value=value), return_type=return_type+ )+ submitted["default_value"] = default+ response = self.post_flag({"key": "typed-v2", "filters": submitted})+ assert response.status_code == status.HTTP_201_CREATED, response.json()+ flag = FeatureFlag.objects.get(team=self.team, key="typed-v2")+ assert [rule["value"] for rule in flag.filters["rules"]] == [value, value]+ assert (flag.filters["return_type"], flag.filters["default_value"]) == (return_type, default)+ read = self.client.get(f"/api/projects/{self.team.id}/feature_flags/{flag.id}/")+ assert read.json()["filters"] == flag.filters++ @parameterized.expand(+ [+ ("string_bool_default", "string", True, "compact", "filters.default_value"),+ ("string_empty_value", "string", None, "", "filters.rules[0].value"),+ ("number_string_value", "number", 0, "1", "filters.rules[0].value"),+ ("number_unsafe_integer", "number", 2**53, 1, "filters.default_value"),+ ("object_array_value", "object", None, [1], "filters.rules[0].value"),+ ("object_too_deep", "object", None, {"a": nested_list(20)}, "filters.rules[0].value"),+ ]+ )+ def test_values_that_do_not_match_the_return_type_are_rejected(+ self, _name: str, return_type: str, default: JsonValue, value: JsonValue, attr: str+ ) -> None:+ submitted = config(targeted(rule_id=None, value=value), return_type=return_type)+ submitted["default_value"] = default+ response = self.post_flag({"key": "typed-v2", "filters": submitted})+ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert response.json()["detail"].startswith(f"{attr}: "), response.json()+ assert not FeatureFlag.objects.filter(team=self.team, key="typed-v2").exists()+def test_active_on_create_is_rejected_not_downgraded(self) -> None:response = self.post_flag({"key": "new-v2", "filters": config(targeted(rule_id=None)), "active": True})assert response.status_code == status.HTTP_400_BAD_REQUESTdiff --git a/products/feature_flags/backend/api/test/test_feature_flag_config_v2_updates.py b/products/feature_flags/backend/api/test/test_feature_flag_config_v2_updates.pyindex 7bfe7083dc81..906a238aa22f 100644--- a/products/feature_flags/backend/api/test/test_feature_flag_config_v2_updates.py+++ b/products/feature_flags/backend/api/test/test_feature_flag_config_v2_updates.py@@ -40,6 +40,9 @@ SEED_B = "7c9e6f82-1a2b-4c3d-9e8f-5a6b7c8d9e0f"UNKNOWN_RULE = "00000000-0000-4000-8000-000000000000"+type JsonValue = bool | int | float | str | None | list["JsonValue"] | dict[str, "JsonValue"]++def admit_v2(team_id: int, *, creation: bool = False):"""Turn the writer flags on for one project the way the local flag client would answer."""enabled = {config_writes.V2_WRITES_FLAG} | ({config_writes.V2_CREATION_FLAG} if creation else set())@@ -315,6 +318,43 @@ class TestAdmittedV2Updates(AdmittedV2TestCase):flag.refresh_from_db()assert flag.filters == document+ @parameterized.expand(+ [+ ("string", "compact", "compact"),+ ("number", 2, 2.0),+ ("object", {"a": 1, "b": [True]}, {"b": [True], "a": 1}),+ ]+ )+ def test_typed_documents_replace_and_report_warnings(+ self, return_type: str, upper: JsonValue, lower: JsonValue+ ) -> None:+ flag = self.flag(+ config(targeted(value=upper), rollout(value=upper), return_type=return_type, default_value=None)+ )+ # The same JSON value, spelled differently, below a partial rollout that continues on a miss.+ document = config(rollout(value=upper), targeted(value=lower), return_type=return_type, default_value=None)+ with patch("products.feature_flags.backend.api.feature_flag.logger.info") as info:+ response = self.patch_flag(flag, {"version": 3, "filters": document})+ assert response.status_code == status.HTTP_200_OK, response.json()+ flag.refresh_from_db()+ assert flag.filters == document+ assert info.call_args.kwargs["extra"]["codes"] == ["ROLLOUT_MISS_CAN_ENTER_LOWER_RULE"]++ @parameterized.expand(+ [+ ("values_of_the_new_type", config(targeted(value="compact"), return_type="string", default_value=None)),+ ("only_the_type", config(targeted(), return_type="string")),+ ]+ )+ def test_return_type_cannot_change(self, _name: str, document: dict) -> None:+ flag = self.flag()+ stored = copy.deepcopy(flag.filters)+ response = self.patch_flag(flag, {"version": 3, "filters": document})+ assert response.status_code == status.HTTP_400_BAD_REQUEST+ assert response.json()["detail"] == "filters.return_type: Cannot be changed after the flag is created."+ flag.refresh_from_db()+ assert (flag.filters, flag.version) == (stored, 3)+@parameterized.expand([("zero", 0), ("hundred", 100), ("two_decimals", 33.33)])def test_percentages_round_trip(self, _name: str, percentage: Any) -> None:flag = self.flag()@@ -549,7 +589,7 @@ class TestV2AdmissionBoundary(AdmittedV2TestCase):[("malformed", {"version": 2, "rules": "broken"}),("deferred_experiment", config({"id": RULE_A, "rule_type": "experiment", "targeting": {}})),- ("deferred_string", config(return_type="string")),+ ("string_with_boolean_default", config(return_type="string")),])def test_unsupported_stored_configs_are_not_replaced(self, _name: str, stored: dict) -> None:diff --git a/products/feature_flags/backend/facade/config_validation.py b/products/feature_flags/backend/facade/config_validation.pyindex e42739901d64..333ab7bca9a8 100644--- a/products/feature_flags/backend/facade/config_validation.py+++ b/products/feature_flags/backend/facade/config_validation.py@@ -12,10 +12,10 @@ request input into the final document, calls ``rule_warnings.review_config`` (whvalidates through this module and reports warnings) and persists under the existing rowlock. No production caller exists yet.-Admitted family: person-assigned boolean flags with targeted_release and+Admitted family: person-assigned flags of every return type with targeted_release andpercentage_rollout rules whose targeting uses person properties. Everything else the-published contract describes (string/number/object values, experiment rules, group-assignment, cohort/group/flag properties) is rejected with the ``unsupported`` code, so a+published contract describes (experiment rules, group assignment, cohort/group/flag+properties) is rejected with the ``unsupported`` code, so acanonical fixture is never relabelled as malformed and no partially checked document isaccepted. Shape errors use the other codes. The canonical shape is the harness configschema 1.0.0 in contract package 2.0.0; the semantic constraints (unique rule ids, two@@ -28,8 +28,9 @@ import jsonfrom collections.abc import Callable, Mappingfrom dataclasses import fieldfrom decimal import Decimal-from typing import Any, Literal, get_args+from typing import Any, Literal, TypeGuard, get_args+from posthog.hogql.constants import FEATURE_FLAG_FALSE_VARIANT_SENTINELfrom posthog.hogql.property import parse_semverfrom posthog.dataclasses import frozen@@ -43,6 +44,8 @@ MAX_RULES = 100MAX_PREDICATES_PER_RULE = 100MAX_SEED_LENGTH = 400MAX_PERCENTAGE_DECIMALS = 2+MAX_SAFE_INTEGER = 2**53 - 1+MAX_OBJECT_DEPTH = 20ConfigErrorCode = Literal["required", "invalid", "unknown_field", "not_unique", "unsupported", "limit_exceeded"]RolloutMissPolicy = Literal["continue", "return_default"]@@ -185,7 +188,7 @@ class ValidatedRule:id: strrule_type: AdmittedRuleTypepredicates: frozenset[Predicate]- value: bool+ value: str # canonical JSON text, see ``canonical_value``rollout_percentage: Decimal | None = Noneon_rollout_miss: RolloutMissPolicy | None = None# Assignment seeds must not reach logs or tracebacks; the detectors only compare them.@@ -194,9 +197,9 @@ class ValidatedRule:@frozenclass ValidatedConfig:- """An admitted person-assigned boolean config; the family is fixed, so only the evaluated fields vary."""+ """An admitted person-assigned config; the family is fixed, so only the evaluated fields vary."""- default_value: bool | None+ default_value: str | None # canonical JSON text; None is a null defaultrules: tuple[ValidatedRule, ...] # stored order, which is evaluation order@@ -227,20 +230,19 @@ def validate_config(document: object, *, limits: ValidationLimits) -> ValidatedCv1_detail = "Config version 1 fields are not allowed in a config version 2 document."errors.append(_unknown_field(f"filters.{name}", v1_detail if name in _V1_ONLY_ROOT_FIELDS else None))- return_type_ok = _field(document, "return_type", "filters", errors, _one_of(RETURN_TYPES))- boolean_family = return_type_ok and document["return_type"] == "boolean"- if return_type_ok and not boolean_family:- errors.append(- ConfigError(- code="unsupported",- detail=f"Flags returning a {document['return_type']} are not available yet. Only boolean is available.",- attr="filters.return_type",- )- )+ value_check = None+ if _field(document, "return_type", "filters", errors, _one_of(RETURN_TYPES)):+ value_check = _VALUE_CHECKS[document["return_type"]]if "default_value" not in document:errors.append(_required("filters.default_value"))- elif boolean_family and not _is_bool_or_none(document["default_value"]):- errors.append(ConfigError(code="invalid", detail="Must be true, false or null.", attr="filters.default_value"))+ elif value_check is not None and document["default_value"] is not None:+ accepts, detail = value_check+ if not accepts(document["default_value"]):+ errors.append(+ ConfigError(+ code="invalid", detail=f"{detail.removesuffix('.')}, or null.", attr="filters.default_value"+ )+ )if _field(document, "aggregation_group_type_index", "filters", errors, (_is_int, "Must be an integer."), False):errors.append(ConfigError(@@ -261,7 +263,7 @@ def validate_config(document: object, *, limits: ValidationLimits) -> ValidatedCelse:seen_ids: set[str] = set()for index, rule in enumerate(document["rules"]):- validated = _validate_rule(rule, f"filters.rules[{index}]", boolean_family, limits, errors)+ validated = _validate_rule(rule, f"filters.rules[{index}]", value_check, limits, errors)if validated is None:continueif validated.id in seen_ids:@@ -275,11 +277,32 @@ def validate_config(document: object, *, limits: ValidationLimits) -> ValidatedCif errors:raise ConfigValidationError(errors)- return ValidatedConfig(default_value=document["default_value"], rules=tuple(rules))+ default = document["default_value"]+ return ValidatedConfig(default_value=None if default is None else canonical_value(default), rules=tuple(rules))+++def canonical_value(value: object) -> str:+ """JSON text that is equal for two values exactly when they are equal JSON values.++ Plain Python equality is not JSON equality (``True == 1``) and objects are unhashable,+ so validated values carry this form. Integral floats print as integers, so ``1.0`` and+ ``-0.0`` read as ``1`` and ``0``.+ """+ return json.dumps(_integral_floats_as_ints(value), sort_keys=True, separators=(",", ":"), ensure_ascii=False)+++def _integral_floats_as_ints(value: object) -> object:+ if isinstance(value, float) and value.is_integer():+ return int(value)+ if isinstance(value, Mapping):+ return {key: _integral_floats_as_ints(item) for key, item in value.items()}+ if isinstance(value, list):+ return [_integral_floats_as_ints(item) for item in value]+ return valuedef _validate_rule(- rule: object, path: str, boolean_family: bool, limits: ValidationLimits, errors: list[ConfigError]+ rule: object, path: str, value_check: "_Check | None", limits: ValidationLimits, errors: list[ConfigError]) -> ValidatedRule | None:if not isinstance(rule, Mapping):errors.append(ConfigError(code="invalid", detail="Must be an object.", attr=path))@@ -303,8 +326,8 @@ def _validate_rule(_field(rule, "description", path, errors, (lambda v: isinstance(v, str), "Must be a string."), False)if "metadata" in rule:_validate_metadata(rule["metadata"], f"{path}.metadata", limits, errors)- if boolean_family:- _field(rule, "value", path, errors, (lambda v: isinstance(v, bool), "Must be true or false."))+ if value_check is not None:+ _field(rule, "value", path, errors, value_check)rollout: Decimal | None = Noneif rule_type == "percentage_rollout":@@ -318,13 +341,13 @@ def _validate_rule(_field(rule, "seed", path, errors, seed_ok)_field(rule, "assign_by", path, errors, _one_of((PERSON_ASSIGNMENT,)), False)- if len(errors) > before or predicates is None or not boolean_family:+ if len(errors) > before or predicates is None or value_check is None:return Nonereturn ValidatedRule(id=rule["id"],rule_type=rule_type,predicates=predicates,- value=rule["value"],+ value=canonical_value(rule["value"]),rollout_percentage=rollout,on_rollout_miss=rule["on_rollout_miss"] if rollout is not None else None,seed=rule["seed"] if rollout is not None else None,@@ -509,6 +532,37 @@ def _unknown_field(attr: str, detail: str | None = None) -> ConfigError:return ConfigError(code="unknown_field", detail=detail or "Unknown field.", attr=attr)+def _is_safe_number(value: object) -> bool:+ return _is_number(value) and -MAX_SAFE_INTEGER <= value <= MAX_SAFE_INTEGER+++def _is_object_value(value: object) -> bool:+ return isinstance(value, Mapping) and _is_nested_value(value, depth=1)+++def _is_nested_value(value: object, *, depth: int) -> bool:+ """Depth counts object and array containers, with the returned object at level 1."""+ if isinstance(value, Mapping | list):+ items = value.values() if isinstance(value, Mapping) else value+ return depth <= MAX_OBJECT_DEPTH and all(_is_nested_value(item, depth=depth + 1) for item in items)+ return value is None or isinstance(value, bool | str) or _is_safe_number(value)+++_VALUE_CHECKS: dict[str, _Check] = {+ "boolean": (lambda v: isinstance(v, bool), "Must be true or false."),+ # A string is served as the variant, and `$false` is the event-storage sentinel that v1 reserves as a variant key.+ "string": (+ lambda v: isinstance(v, str) and v not in ("", FEATURE_FLAG_FALSE_VARIANT_SENTINEL),+ f"Must be a non-empty string other than {FEATURE_FLAG_FALSE_VARIANT_SENTINEL}.",+ ),+ "number": (_is_safe_number, f"Must be a number from -{MAX_SAFE_INTEGER} to {MAX_SAFE_INTEGER}."),+ "object": (+ _is_object_value,+ f"Must be an object at most {MAX_OBJECT_DEPTH} levels deep with numbers from -{MAX_SAFE_INTEGER} to {MAX_SAFE_INTEGER}.",+ ),+}++def _is_bool_or_none(value: object) -> bool:return value is None or isinstance(value, bool)@@ -517,7 +571,7 @@ def _is_int(value: object) -> bool:return not isinstance(value, bool) and isinstance(value, int)-def _is_number(value: object) -> bool:+def _is_number(value: object) -> TypeGuard[int | float]:if isinstance(value, bool) or not isinstance(value, int | float):return Falsereturn -sys.float_info.max <= value <= sys.float_info.maxdiff --git a/products/feature_flags/backend/facade/config_writes.py b/products/feature_flags/backend/facade/config_writes.pyindex a55bc1f0030e..4219cb2450a8 100644--- a/products/feature_flags/backend/facade/config_writes.py+++ b/products/feature_flags/backend/facade/config_writes.py@@ -217,6 +217,20 @@ def review_update(# preventing a replacement that brings them back within the write limits.unbounded = ValidationLimits(max_config_bytes=sys.maxsize, max_metadata_bytes=sys.maxsize)current = _validated_stored(stored, limits=unbounded, operation="updated") if stored else None+ # Checked first, so a changed type is not reported as values that do not match it.+ if (+ current is not None+ and isinstance(document, Mapping)+ and "return_type" in document+ and document["return_type"] != stored["return_type"]+ ):+ raise ConfigValidationError(+ [+ ConfigError(+ code="invalid", detail="Cannot be changed after the flag is created.", attr="filters.return_type"+ )+ ]+ )return review_config(document, limits=limits, current=current).warningsdiff --git a/products/feature_flags/backend/facade/rule_warnings.py b/products/feature_flags/backend/facade/rule_warnings.pyindex eab21086766f..7a7e8e23ab79 100644--- a/products/feature_flags/backend/facade/rule_warnings.py+++ b/products/feature_flags/backend/facade/rule_warnings.py@@ -184,7 +184,7 @@ def _overlap(a: ValidatedRule, b: ValidatedRule) -> frozenset[Predicate] | None:@frozenclass _Outcome:- value: bool | None # the value served: the rule's, or the config default on a terminal miss+ value: str | None # canonical JSON of the value served: the rule's, or the config default on a terminal missserved: bool # True when the rule's own value was served, False for a terminal missrule_index: intdiff --git a/products/feature_flags/backend/test/test_facade_config_validation.py b/products/feature_flags/backend/test/test_facade_config_validation.pyindex 06350fbf7cad..215b968eb443 100644--- a/products/feature_flags/backend/test/test_facade_config_validation.py+++ b/products/feature_flags/backend/test/test_facade_config_validation.py@@ -22,8 +22,10 @@ from products.feature_flags.backend.facade.config_validation import (_ROOT_FIELDS,_UUID as UUID_PATTERN,ASSIGNMENT_ALGORITHM,+ MAX_OBJECT_DEPTH,MAX_PREDICATES_PER_RULE,MAX_RULES,+ MAX_SAFE_INTEGER,MAX_SEED_LENGTH,PERSON_ASSIGNMENT,PROPERTY_OPERATORS,@@ -37,6 +39,7 @@ from products.feature_flags.backend.facade.config_validation import (ValidatedRule,ValidationLimits,_encoded_size as config_size_bytes,+ canonical_value,validate_config,)@@ -81,6 +84,14 @@ def config(*rules: dict[str, Any], **overrides: Any) -> dict[str, Any]:return {"version": 2, "return_type": "boolean", "default_value": False, "rules": list(rules), **overrides}+def nested(depth: int, leaf: Any = True) -> dict[str, Any]:+ """An object ``depth`` containers deep, counting itself as level 1."""+ value: Any = {"leaf": leaf}+ for _ in range(depth - 1):+ value = {"child": value}+ return value++def without(document: dict[str, Any], key: str) -> dict[str, Any]:return {name: value for name, value in document.items() if name != key}@@ -162,6 +173,28 @@ VALID_DOCUMENTS: list[tuple[str, dict[str, Any]]] = [)),),+ (+ "string_values",+ config(targeted(value="compact"), rollout(value="wide"), return_type="string", default_value="standard"),+ ),+ ("string_null_default", config(targeted(value="compact"), return_type="string", default_value=None)),+ ("number_values", config(targeted(value=1.25), rollout(value=-40), return_type="number", default_value=0)),+ (+ "number_safe_integer_bounds",+ config(+ targeted(value=MAX_SAFE_INTEGER), rollout(value=-MAX_SAFE_INTEGER), return_type="number", default_value=None+ ),+ ),+ (+ "object_values",+ config(+ targeted(value={"layout": "compact", "options": [1, True, None]}),+ rollout(value={}),+ return_type="object",+ default_value={"layout": "standard"},+ ),+ ),+ ("object_max_depth", config(targeted(value=nested(MAX_OBJECT_DEPTH)), return_type="object", default_value=None)),("max_rules", config(*[targeted(id=f"00000000-0000-4000-8000-{index:012d}") for index in range(MAX_RULES)])),("max_predicates",@@ -191,9 +224,70 @@ INVALID_DOCUMENTS: list[tuple[str, object, list[tuple[str, str]]]] = [("missing_return_type", without(config(), "return_type"), [("required", "filters.return_type")]),("return_type_unknown", config(return_type="json"), [("invalid", "filters.return_type")]),("return_type_null", config(return_type=None), [("invalid", "filters.return_type")]),- ("return_type_string", config(return_type="string", default_value="a"), [("unsupported", "filters.return_type")]),- ("return_type_number", config(return_type="number", default_value=0), [("unsupported", "filters.return_type")]),- ("return_type_object", config(return_type="object", default_value={}), [("unsupported", "filters.return_type")]),+ ("string_empty_default", config(return_type="string", default_value=""), [("invalid", "filters.default_value")]),+ ("string_bool_default", config(return_type="string", default_value=True), [("invalid", "filters.default_value")]),+ (+ "string_empty_value",+ config(targeted(value=""), return_type="string", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "string_bool_value",+ config(targeted(value=True), return_type="string", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "string_reserved_false_sentinel",+ config(targeted(value="$false"), return_type="string", default_value="$false"),+ [("invalid", "filters.default_value"), ("invalid", "filters.rules[0].value")],+ ),+ ("number_bool_default", config(return_type="number", default_value=False), [("invalid", "filters.default_value")]),+ (+ "number_string_value",+ config(targeted(value="1.25"), return_type="number", default_value=0),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "number_above_safe_integer",+ config(rollout(value=MAX_SAFE_INTEGER + 1), return_type="number", default_value=0),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "number_below_safe_integer",+ config(return_type="number", default_value=-float(MAX_SAFE_INTEGER + 1)),+ [("invalid", "filters.default_value")],+ ),+ (+ "number_not_finite",+ config(targeted(value=float("inf")), return_type="number", default_value=0),+ [("invalid", "filters.rules[0].value")],+ ),+ ("object_string_default", config(return_type="object", default_value="{}"), [("invalid", "filters.default_value")]),+ (+ "object_array_value",+ config(targeted(value=[{"layout": "compact"}]), return_type="object", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "object_too_deep",+ config(targeted(value=nested(MAX_OBJECT_DEPTH + 1)), return_type="object", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "object_array_too_deep",+ config(targeted(value={"list": nested(MAX_OBJECT_DEPTH - 1, [])}), return_type="object", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "object_nested_number_above_safe_integer",+ config(targeted(value={"limit": [MAX_SAFE_INTEGER + 1]}), return_type="object", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),+ (+ "object_null_value",+ config(targeted(value=None), return_type="object", default_value=None),+ [("invalid", "filters.rules[0].value")],+ ),("missing_default", without(config(), "default_value"), [("required", "filters.default_value")]),("default_zero", config(default_value=0), [("invalid", "filters.default_value")]),("default_one", config(default_value=1), [("invalid", "filters.default_value")]),@@ -625,9 +719,54 @@ class TestValidateConfig:assert str(exc_info.value) == "filters.future: Unknown field."def test_unsupported_family_is_reported_before_shape_of_its_values(self) -> None:- # A canonical string document is refused for the family, not for values this validator cannot judge.- document = config(targeted(value="compact"), return_type="string", default_value="standard")- assert errors_of(document) == [("unsupported", "filters.return_type")]+ # The unsupported family is reported first. The rule value is still checked against the boolean return type.+ document = config(targeted(value=1), aggregation_group_type_index=0)+ assert errors_of(document) == [+ ("unsupported", "filters.aggregation_group_type_index"),+ ("invalid", "filters.rules[0].value"),+ ]++ @parameterized.expand(+ [+ ("boolean", True, True, "true", "true"),+ ("string", "compact", "compact", '"compact"', '"compact"'),+ ("number", 1.0, -0.0, "1", "0"),+ ("object", {"b": [1.0, True], "a": "ü"}, {"b": [1.0, True]}, '{"a":"ü","b":[1,true]}', '{"b":[1,true]}'),+ ]+ )+ def test_values_are_canonical_json_so_equal_json_values_compare_equal(+ self, return_type: str, value: Any, default: Any, canonical: str, canonical_default: str+ ) -> None:+ validated = validate_config(+ config(targeted(value=value), return_type=return_type, default_value=default), limits=LIMITS+ )+ assert validated.rules[0].value == canonical+ assert validated.default_value == canonical_default+ assert canonical_value(True) != canonical_value(1)+ assert canonical_value({"n": 1}) == canonical_value({"n": 1.0}) != canonical_value({"n": True})++ @parameterized.expand(+ [+ ("boolean", 1, "Must be true or false"),+ ("string", "$false", "Must be a non-empty string other than $false"),+ ("number", "1", "Must be a number from -9007199254740991 to 9007199254740991"),+ (+ "object",+ [],+ "Must be an object at most 20 levels deep with numbers from -9007199254740991 to 9007199254740991",+ ),+ ]+ )+ def test_value_errors_name_the_type_and_allow_null_only_for_the_default(+ self, return_type: str, invalid: Any, message: str+ ) -> None:+ document = config(targeted(value=invalid), return_type=return_type, default_value=invalid)+ with pytest.raises(ConfigValidationError) as exc_info:+ validate_config(document, limits=LIMITS)+ assert [(error.attr, error.detail) for error in exc_info.value.errors] == [+ ("filters.default_value", f"{message}, or null."),+ ("filters.rules[0].value", f"{message}."),+ ]def test_v1_only_fields_name_the_format_clash(self) -> None:with pytest.raises(ConfigValidationError) as exc_info:@@ -674,13 +813,13 @@ class TestValidateConfig:Predicate(key="beta", operator="is_set", value="null", negation=False),}),- value=True,+ value="true",),ValidatedRule(id=ROLLOUT_ID,rule_type="percentage_rollout",predicates=frozenset(),- value=True,+ value="true",rollout_percentage=Decimal("33.33"),on_rollout_miss="continue",seed=SEED,@@ -722,8 +861,7 @@ def _admitted_family(document: dict[str, Any]) -> bool:if isinstance(prop, dict)]return (- document.get("return_type") == "boolean"- and "aggregation_group_type_index" not in document+ "aggregation_group_type_index" not in documentand all(rule.get("rule_type") != "experiment" for rule in rules)and all(prop.get("type") == "person" for prop in properties))@@ -765,6 +903,8 @@ class TestReleasedContract:assert MAX_PREDICATES_PER_RULE == CONFIG_SCHEMA["$defs"]["targeting"]["properties"]["properties"]["maxItems"]assert MAX_SEED_LENGTH == CONFIG_SCHEMA["$defs"]["seed"]["maxLength"]assert UUID_PATTERN.pattern == CONFIG_SCHEMA["$defs"]["uuid"]["pattern"]+ safe_number = CONFIG_SCHEMA["$defs"]["safeNumber"]+ assert (safe_number["minimum"], safe_number["maximum"]) == (-MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)assert set(RETURN_TYPES) == {entry["value"] for entry in registry["return_types"]}assert set(RULE_TYPES) == {entry["value"] for entry in registry["rule_types"]}@@ -804,7 +944,11 @@ class TestReleasedContract:errors = errors_of(document)if _admitted_family(document):expected_attr = _contract_path(entry["expected_failure"]["instance_path"], entry["expected_failure"])- assert any(code != "unsupported" and attr == expected_attr for code, attr in errors), (+ # A value is one field here, so a failure the schema locates inside it is reported on the value.+ assert any(+ code != "unsupported" and (attr == expected_attr or expected_attr.startswith(f"{attr}."))+ for code, attr in errors+ ), (errors,expected_attr,)diff --git a/products/feature_flags/backend/test/test_facade_rule_warnings.py b/products/feature_flags/backend/test/test_facade_rule_warnings.pyindex f24472e7f7c9..e6844832cbbb 100644--- a/products/feature_flags/backend/test/test_facade_rule_warnings.py+++ b/products/feature_flags/backend/test/test_facade_rule_warnings.py@@ -14,6 +14,7 @@ from products.feature_flags.backend.facade.config_validation import (RolloutMissPolicy,ValidatedConfig,ValidatedRule,+ canonical_value,)from products.feature_flags.backend.facade.rule_warnings import (ConfigReview,@@ -44,14 +45,16 @@ PLAN_SET_NEGATED = Predicate(key="plan", operator="is_set", value="null", negatiCOUNTRY_NOT_SET = Predicate(key="country", operator="is_not_set", value="null", negation=False)-def targeted(rule_id: str, value: bool = True, *predicates: Predicate) -> ValidatedRule:- return ValidatedRule(id=rule_id, rule_type="targeted_release", predicates=frozenset(predicates), value=value)+def targeted(rule_id: str, value: Any = True, *predicates: Predicate) -> ValidatedRule:+ return ValidatedRule(+ id=rule_id, rule_type="targeted_release", predicates=frozenset(predicates), value=canonical_value(value)+ )def rollout(rule_id: str,percentage: int | float | str,- value: bool = True,+ value: Any = True,*predicates: Predicate,seed: str = SEED,miss: RolloutMissPolicy = "continue",@@ -60,15 +63,15 @@ def rollout(id=rule_id,rule_type="percentage_rollout",predicates=frozenset(predicates),- value=value,+ value=canonical_value(value),rollout_percentage=Decimal(str(percentage)),on_rollout_miss=miss,seed=seed,)-def cfg(*rules: ValidatedRule, default: bool | None = False) -> ValidatedConfig:- return ValidatedConfig(default_value=default, rules=rules)+def cfg(*rules: ValidatedRule, default: Any = False) -> ValidatedConfig:+ return ValidatedConfig(default_value=None if default is None else canonical_value(default), rules=rules)def codes(warnings: tuple[ManagementWarning, ...]) -> list[tuple[str, str | None]]:@@ -466,6 +469,32 @@ class TestReviewConfig:True,]+ @parameterized.expand(+ [+ ("string_same", "string", "compact", "compact", True),+ ("string_different", "string", "compact", "wide", False),+ ("number_integral_float", "number", 2, 2.0, True),+ ("number_different", "number", 2, 2.5, False),+ ("object_key_order", "object", {"a": 1, "b": [True]}, {"b": [True], "a": 1.0}, True),+ ("object_true_is_not_one", "object", {"a": True}, {"a": 1}, False),+ ]+ )+ def test_typed_values_are_compared_as_json(+ self, _name: str, return_type: str, upper: Any, lower: Any, same_value: bool+ ) -> None:+ document = {**deepcopy(ROLLOUT_DOCUMENT), "return_type": return_type, "default_value": None}+ document["rules"] = document["rules"][:2]+ document["rules"][0]["value"] = upper+ document["rules"][1]["value"] = lower+ assert codes(review_config(document, limits=LIMITS).warnings) == (+ [(EXTENDS, "filters.rules[1]")] if same_value else []+ )+ reordered = {**document, "rules": document["rules"][::-1]}+ current = review_config(document, limits=LIMITS).config+ assert (+ REORDER in [code for code, _ in codes(review_config(reordered, limits=LIMITS, current=current).warnings)]+ ) != same_value+def test_invalid_candidate_raises_before_any_warning(self) -> None:with pytest.raises(ConfigValidationError):review_config({**ROLLOUT_DOCUMENT, "default_value": 0}, limits=LIMITS)diff --git a/rust/feature-flags/src/flags/config_format/tests.rs b/rust/feature-flags/src/flags/config_format/tests.rsindex 909894e86d0d..71cdc9bbe6fe 100644--- a/rust/feature-flags/src/flags/config_format/tests.rs+++ b/rust/feature-flags/src/flags/config_format/tests.rs@@ -108,7 +108,7 @@ fn v2_ingress_counts_parse_outcomes_without_configuration_labels() {let mut malformed = valid.clone();malformed["default_value"] = json!("invalid");let mut unsupported = valid.clone();- unsupported["return_type"] = json!("string");+ unsupported["aggregation_group_type_index"] = json!(0);let mut oversized = valid.clone();oversized["extra"] = json!("x".repeat(*config_v2::MAX_CONFIG_BYTES));metrics::with_local_recorder(&recorder, || {diff --git a/rust/feature-flags/src/flags/config_v2.rs b/rust/feature-flags/src/flags/config_v2.rsindex 2385a27dd0f1..75021d3cc49f 100644--- a/rust/feature-flags/src/flags/config_v2.rs+++ b/rust/feature-flags/src/flags/config_v2.rs@@ -6,6 +6,8 @@ use serde_json::value::RawValue;use serde_json::{Map, Value};use uuid::Uuid;+use crate::utils::json_size::estimate_json_heap_size;+mod properties;mod raw;pub use properties::PersonPredicate;@@ -23,6 +25,8 @@ pub static MAX_CONFIG_BYTES: Lazy<usize> = Lazy::new(|| {pub const MAX_RULES: usize = 100;pub const MAX_PREDICATES: usize = 100;pub const MAX_SEED_LENGTH: usize = 400;+pub const MAX_SAFE_INTEGER: f64 = 9_007_199_254_740_991.0;+pub const MAX_OBJECT_DEPTH: usize = 20;pub const CONFIG_FIELDS: &[&str] = &["version","return_type",@@ -100,7 +104,7 @@ impl NonV1Config {#[derive(Clone)]pub struct Config {- pub default_value: Option<bool>,+ pub default_value: Option<Value>,pub rules: Vec<Rule>,}@@ -114,10 +118,10 @@ pub struct Rule {#[derive(Clone)]pub enum Outcome {TargetedRelease {- value: bool,+ value: Value,},PercentageRollout {- value: bool,+ value: Value,rollout_percentage: f64,on_rollout_miss: RolloutMiss,seed: String,@@ -159,13 +163,13 @@ impl fmt::Debug for Outcome {impl Config {pub(super) fn parse(document: &Map<String, Value>) -> Result<Self, ParseError> {closed(document, CONFIG_FIELDS, "filters")?;- match string(document, "return_type")? {- "boolean" => {}- "string" | "number" | "object" => {- return Err(ParseError::Unsupported("return_type"));- }+ let return_type = match string(document, "return_type")? {+ "boolean" => ReturnType::Boolean,+ "string" => ReturnType::String,+ "number" => ReturnType::Number,+ "object" => ReturnType::Object,_ => return Err(ParseError::Malformed("return_type")),- }+ };if let Some(group) = document.get("aggregation_group_type_index") {if !group.as_f64()@@ -177,7 +181,7 @@ impl Config {}let default_value = match required(document, "default_value")? {Value::Null => None,- Value::Bool(value) => Some(*value),+ value if return_type.accepts(value) => Some(value.clone()),_ => return Err(ParseError::Malformed("default_value")),};let rules = required(document, "rules")?@@ -190,7 +194,7 @@ impl Config {let rules = rules.iter().map(|value| {- let rule = Rule::parse(value)?;+ let rule = Rule::parse(value, return_type)?;if !seen.insert(rule.id) {return Err(ParseError::Malformed("rule.id"));}@@ -205,7 +209,10 @@ impl Config {#[doc(hidden)]pub fn estimated_heap_bytes(&self) -> usize {- self.rules.capacity() * std::mem::size_of::<Rule>()+ self.default_value+ .as_ref()+ .map_or(0, estimate_json_heap_size)+ + self.rules.capacity() * std::mem::size_of::<Rule>()+ self.rules.iter()@@ -215,7 +222,7 @@ impl Config {}impl Rule {- fn parse(value: &Value) -> Result<Self, ParseError> {+ fn parse(value: &Value, return_type: ReturnType) -> Result<Self, ParseError> {let rule = object(value, "rule")?;let rule_type = string(rule, "rule_type")?;let fields: &[&str] = match rule_type {@@ -238,9 +245,11 @@ impl Rule {return Err(ParseError::Malformed("metadata"));}let targeting = properties::parse_targeting(required(rule, "targeting")?)?;- let value = required(rule, "value")?- .as_bool()- .ok_or(ParseError::Malformed("value"))?;+ let value = required(rule, "value")?;+ if !return_type.accepts(value) {+ return Err(ParseError::Malformed("value"));+ }+ let value = value.clone();let outcome = if rule_type == "targeted_release" {Outcome::TargetedRelease { value }} else {@@ -284,12 +293,54 @@ impl Rule {.map(PersonPredicate::estimated_heap_bytes).sum::<usize>()+ match &self.outcome {- Outcome::PercentageRollout { seed, .. } => seed.capacity(),- Outcome::TargetedRelease { .. } => 0,+ Outcome::PercentageRollout { seed, value, .. } => {+ seed.capacity() + estimate_json_heap_size(value)+ }+ Outcome::TargetedRelease { value } => estimate_json_heap_size(value),}}}+#[derive(Clone, Copy)]+enum ReturnType {+ Boolean,+ String,+ Number,+ Object,+}++impl ReturnType {+ /// Whether `value` is a non-null value of this type; a null default is handled by the caller.+ fn accepts(self, value: &Value) -> bool {+ match self {+ Self::Boolean => value.is_boolean(),+ Self::String => value.as_str().is_some_and(|s| !s.is_empty()),+ Self::Number => is_safe_number(value),+ Self::Object => value.is_object() && is_nested_value(value, 1),+ }+ }+}++fn is_safe_number(value: &Value) -> bool {+ value+ .as_f64()+ .is_some_and(|n| (-MAX_SAFE_INTEGER..=MAX_SAFE_INTEGER).contains(&n))+}++/// Depth counts object and array containers, with the returned object at level 1.+fn is_nested_value(value: &Value, depth: usize) -> bool {+ match value {+ Value::Object(map) => {+ depth <= MAX_OBJECT_DEPTH && map.values().all(|v| is_nested_value(v, depth + 1))+ }+ Value::Array(items) => {+ depth <= MAX_OBJECT_DEPTH && items.iter().all(|v| is_nested_value(v, depth + 1))+ }+ Value::Number(_) => is_safe_number(value),+ Value::Null | Value::Bool(_) | Value::String(_) => true,+ }+}+fn percentage(value: &Value) -> Result<f64, ParseError> {let error = ParseError::Malformed("rollout_percentage");let Value::Number(number) = value else {diff --git a/rust/feature-flags/src/flags/evaluate_v2.rs b/rust/feature-flags/src/flags/evaluate_v2.rsindex 8dd0a37f9a85..662d3168a6f3 100644--- a/rust/feature-flags/src/flags/evaluate_v2.rs+++ b/rust/feature-flags/src/flags/evaluate_v2.rs@@ -31,18 +31,20 @@ pub struct MatchedRule {pub kind: RuleKind,}+/// `value` borrows the parsed JSON of the flag's return type from the configuration; `None`+/// is a null default.#[derive(Clone, Copy, Debug, PartialEq, Eq)]-pub enum Evaluation {+pub enum Evaluation<'a> {TargetingMatch {- value: bool,+ value: &'a Value,rule: MatchedRule,},RolloutMiss {- value: Option<bool>,+ value: Option<&'a Value>,rule: MatchedRule,},NoRuleMatch {- value: Option<bool>,+ value: Option<&'a Value>,},}@@ -101,7 +103,10 @@ impl<'a> Evaluator<'a> {Self { config }}- pub fn evaluate(&self, context: &EvaluationContext<'_>) -> Result<Evaluation, EvaluationError> {+ pub fn evaluate(+ &self,+ context: &EvaluationContext<'_>,+ ) -> Result<Evaluation<'a>, EvaluationError> {self.evaluate_with_hash(context, |seed, subject| {calculate_hash(&format!("{seed}."), subject, "").map_err(|_| EvaluationError::Hash)})@@ -113,7 +118,7 @@ impl<'a> Evaluator<'a> {&self,context: &EvaluationContext<'_>,mut hash: impl FnMut(&str, &str) -> Result<f64, EvaluationError>,- ) -> Result<Evaluation, EvaluationError> {+ ) -> Result<Evaluation<'a>, EvaluationError> {let subject = truncate_chars(context.person_identifier, MAX_DISTINCT_ID_LEN);let matching =PropertyMatchingContext::new(context.timezone, context.use_explicit_exact_matching)@@ -135,7 +140,7 @@ impl<'a> Evaluator<'a> {kind,};let (kind, value) = match &rule.outcome {- Outcome::TargetedRelease { value } => (RuleKind::TargetedRelease, *value),+ Outcome::TargetedRelease { value } => (RuleKind::TargetedRelease, value),Outcome::PercentageRollout {value,rollout_percentage,@@ -156,13 +161,13 @@ impl<'a> Evaluator<'a> {RolloutMiss::Continue => continue,RolloutMiss::ReturnDefault => {return Ok(Evaluation::RolloutMiss {- value: self.config.default_value,+ value: self.config.default_value.as_ref(),rule: matched_rule(RuleKind::PercentageRollout),})}}}- (RuleKind::PercentageRollout, *value)+ (RuleKind::PercentageRollout, value)}};return Ok(Evaluation::TargetingMatch {@@ -171,7 +176,7 @@ impl<'a> Evaluator<'a> {});}Ok(Evaluation::NoRuleMatch {- value: self.config.default_value,+ value: self.config.default_value.as_ref(),})}}diff --git a/rust/feature-flags/src/flags/flag_matching.rs b/rust/feature-flags/src/flags/flag_matching.rsindex 2470fc1d02f2..c11f184bf18f 100644--- a/rust/feature-flags/src/flags/flag_matching.rs+++ b/rust/feature-flags/src/flags/flag_matching.rs@@ -1703,8 +1703,9 @@ impl FeatureFlagMatcher {})}- /// Projects a v2 outcome onto the v1 match shape: `enabled` is the boolean value (null- /// default is false), never a variant or payload; the subject is the request distinct ID.+ /// Projects a v2 outcome onto the v1 match shape: a null value is disabled, a boolean is+ /// `enabled`, a string is the variant, and a number or object is an enabled flag whose value+ /// travels as a JSON-encoded payload, like a v1 payload. The subject is the request distinct ID.fn get_match_v2(&self,config: &Config,@@ -1734,29 +1735,33 @@ impl FeatureFlagMatcher {use_explicit_exact_matching: self.use_explicit_exact_matching,now: self.now,})?;- let (matches, reason, condition_index) = match evaluation {+ let (value, reason, condition_index) = match evaluation {Evaluation::TargetingMatch { value, rule } => (- value,+ Some(value),FeatureFlagMatchReason::ConditionMatch,Some(rule.index),),Evaluation::RolloutMiss { value, rule } => (- value.unwrap_or(false),+ value,FeatureFlagMatchReason::OutOfRolloutBound,Some(rule.index),),- Evaluation::NoRuleMatch { value } => (- value.unwrap_or(false),- FeatureFlagMatchReason::NoConditionMatch,- None,- ),+ Evaluation::NoRuleMatch { value } => {+ (value, FeatureFlagMatchReason::NoConditionMatch, None)+ }+ };+ let (matches, variant, payload) = match value {+ None => (false, None, None),+ Some(Value::Bool(value)) => (*value, None, None),+ Some(Value::String(value)) => (true, Some(value.clone()), None),+ Some(value) => (true, None, Some(Value::String(value.to_string()))),};Ok(FeatureFlagMatch {matches,- variant: None,+ variant,reason,condition_index,- payload: None,+ payload,})}diff --git a/rust/feature-flags/tests/fixtures/flags_cache_config_formats.json b/rust/feature-flags/tests/fixtures/flags_cache_config_formats.jsonindex 2bf9c4c98c8b..3b30eb738cba 100644--- a/rust/feature-flags/tests/fixtures/flags_cache_config_formats.json+++ b/rust/feature-flags/tests/fixtures/flags_cache_config_formats.json@@ -96,6 +96,50 @@},"expect": "kept"},+ {+ "key": "v2-string-active",+ "active": true,+ "filters": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [{ "id": "c3c3c3c3-c3c3-4c3c-8c3c-c3c3c3c3c3c3", "rule_type": "targeted_release", "targeting": { "properties": [] }, "value": "compact" }]+ },+ "expect": "kept"+ },+ {+ "key": "v2-number-active",+ "active": true,+ "filters": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [{ "id": "c3c3c3c3-c3c3-4c3c-8c3c-c3c3c3c3c3c3", "rule_type": "targeted_release", "targeting": { "properties": [] }, "value": -2.5 }]+ },+ "expect": "kept"+ },+ {+ "key": "v2-object-active",+ "active": true,+ "filters": {+ "version": 2,+ "return_type": "object",+ "default_value": {},+ "rules": [{ "id": "c3c3c3c3-c3c3-4c3c-8c3c-c3c3c3c3c3c3", "rule_type": "targeted_release", "targeting": { "properties": [] }, "value": { "layout": "compact", "options": [1, true, null] } }]+ },+ "expect": "kept"+ },+ {+ "key": "v2-string-empty-value-active",+ "active": true,+ "filters": {+ "version": 2,+ "return_type": "string",+ "default_value": null,+ "rules": [{ "id": "c3c3c3c3-c3c3-4c3c-8c3c-c3c3c3c3c3c3", "rule_type": "targeted_release", "targeting": { "properties": [] }, "value": "" }]+ },+ "expect": "unsupported"+ },{"key": "v2-malformed-active","active": true,diff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/README.md b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/README.mdsimilarity index 89%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/README.mdrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/README.mdindex abf4e7c565e0..ede17fa6bacb 100644--- a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/README.md+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/README.md@@ -1,11 +1,10 @@# Feature Flag Rules v2 contractThis package defines Feature Flag Rules v2 configuration, definitions, response, management diagnostic and event contracts, plus the canonical evaluation corpus.-Contract package 2.2.0 contains config schema 1.0.0, registry 2.0.0, corpus 1.1.0, wire schemas/fixtures 1.0.0, and person boolean evaluation corpus 1.0.0.+Contract package 2.3.0 contains config schema 1.0.0, registry 2.0.0, corpus 1.1.0, wire schemas/fixtures 1.0.0, person boolean evaluation corpus 1.0.0, and typed value evaluation corpus 1.0.0.The contract version is independent of the test harness package version.The package does not enable config writes or runtime evaluation.-It reserves number and object values for later writer support.## Terminology and OpenFeature translation@@ -48,6 +47,7 @@ Percentage rollout inclusion maps to TARGETING_MATCH by contract choice; OpenFea- corpus/legacy_projection.json records how a version 1 outcome projects into each response protocol version.- schemas/hash_sha1_60_v1.schema.json, schemas/v1_evaluation.schema.json, and schemas/legacy_projection.schema.json are the companion schemas for the corpus files.- corpus/v2_boolean_evaluation.json contains the person boolean evaluation corpus, and schemas/v2_boolean_evaluation.schema.json is its companion schema.+- corpus/v2_value_evaluation.json contains the string, number and object evaluation corpus with each result's legacy rendering, and schemas/v2_value_evaluation.schema.json is its companion schema.- manifest.json assigns stable fixture and case IDs and declares the compatibility policy.- SHA256SUMS records the SHA-256 digest for each package file except itself.@@ -68,6 +68,7 @@ The config schema stays at 1.0.0 because contract 2.0.0 does not change its publThe literal registry is 2.0.0: it removes the four unused management warning codes (`EXPERIMENT_VALUE_COLLISION`, `SDK_REMOTE_FALLBACK_REQUIRED`, `SDK_EXPERIMENT_CONTEXT_MISSING`, `LEGACY_PROJECTION_LIMITED`) from the `warning_codes` published in registry 1.0.0 (contract 1.2.0), which the compatibility policy classifies as a major change; the five remaining codes are unchanged.The corpus files and their companion schemas are corpus version 1.1.0.Contract package 2.1.0 adds config fixtures for the targeted-release and percentage-rollout family; it changes no published schema, registry, corpus or fixture bytes.+Contract package 2.3.0 adds the typed value evaluation corpus; it also changes no published bytes.## Corpus rules@@ -236,3 +237,32 @@ Eligibility cases run through the existing request boundary and require omissionParser cases require whole-document rejection, separately from evaluation support.The existing published variant/experiment/holdout/group/dependency vectors remain outside this component's evaluator scope.A passing boolean corpus does not establish those families or production reachability.++## Typed value evaluation corpus++Contract 2.3.0 adds `corpus/v2_value_evaluation.json` and its schema as a separate 1.0.0 component for string, number and object flags.+Cases use the boolean corpus case shape and context rules, and `expected` is exhaustive in the same way.+`expected.value` is the typed JSON value, or null when the result delegates to the caller default.+Compare values by JSON type as well as value: the number `1` and the boolean `true` differ.++Ordering rows repeat nine scenarios for each type: a targeted match, a 100 percent rollout hit, a 0 percent rollout miss under `return_default` with a typed and with a null default, a miss under `continue`, no rule match with a typed and with a null default, and first-match ordering with and without a targeting miss.+Rules in one config return different values, so a consumer that reports the wrong rule's value fails.+Value rows cover the value domain: non-ASCII and boolean-looking strings; zero, negative, decimal, exponent and ±(2^53 − 1) numbers; and empty, nested and 20-level objects.+Every number in a value row round-trips through binary64.+Parser rows require whole-document rejection: an empty string, a value or default of the wrong JSON type, a top-level array for an object flag, a number outside ±(2^53 − 1) at any depth, and an object deeper than 20 levels.++### Legacy rendering++Each success row carries `legacy`, the rendering of its value in the response shapes before v3:++| Value | `enabled` | `variant` | Flag map value | Payload |+| --- | --- | --- | --- | --- |+| null | false | null | false | none |+| string | true | the string | the string | none |+| number or object | true | null | true | the value |++`enabled` also decides whether the flag appears in the enabled-only `/decide` map and key list.+Zero and the empty object are values, so they render as enabled.+The payload travels as a JSON-encoded string in `metadata.payload` and `featureFlagPayloads`, like a version 1 payload, so existing payload accessors decode it.+The corpus records the decoded value because key order and number spelling in the encoded string are not canonical; decode before comparing.+A v3 record carries `expected.value` in `value`, and its `metadata.payload` stays null for config version 2, as the wire schema requires.diff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SHA256SUMS b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SHA256SUMSsimilarity index 95%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SHA256SUMSrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SHA256SUMSindex c2556a0f00e6..16ab69907fc0 100644--- a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SHA256SUMS+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SHA256SUMS@@ -1,8 +1,9 @@-de5c6babb9b66abb66f0c245af393de8af2332c4caeecc3dec137b9a9aefcc4d README.md+bd0381b9795baac6ca43dad2a491199854b296761b6f133053b603826ea5898d README.mde9bea9cff58bac0c6c1021e9c8842c53594055b6874a2c58bc4350d0c28a93ca corpus/hash_sha1_60_v1.json536c8386eefa75721d113bd8718ddeb7fb1aad3b4f2cce1fbcf516a346a16e26 corpus/legacy_projection.json752ff88dcb943ab1e21f9552b0c4ec606029393fca2b565b01a497da89cd8675 corpus/v1_evaluation.json2d2a4be5f7185445f6d6593533fe105e436bade1becc3e3b15ff380a8da477bb corpus/v2_boolean_evaluation.json+aaddd05e47fc5a4ae07ea42ada5a659798f4b5fc8d0c0827f6a68e4daf68c128 corpus/v2_value_evaluation.json52d356d2bcdcbf705b0fe2673eb147ac352bda13c9b1bc3d53c4bbb1cb01a5aa fixtures/config/invalid/assign_by_not_person.json516e72b6bd9f761de62166457528242723694f86e417b1aee6eb37b924acc4b5 fixtures/config/invalid/default_value_type_mismatch.jsonf5aa796ba2abf17ab6b2f4706c872f2b15bfa77310cdf0400a3a460db22eda41 fixtures/config/invalid/empty_seed.json@@ -53,7 +54,7 @@ b6398336370d8807b0874229e8dc94ed1f6e686736764d56666fc48021dabf31 fixtures/wire/07499c5a7ca7467968156ee16fa95bdeb9018c0b841c4ec8f5bffc61d72de4fa fixtures/wire/readers.jsone34659b62facbc594bdc1ce6c0f127ff25d94672da332670b383d729f45e5960 fixtures/wire/responses.jsoncaac24e4c78b7086e13eb15768b5fa0eca65992d0cb0b926da5aa5d167d9878b fixtures/wire/warnings.json-43b26f6fea4fa118e60e128156b0d85b1fd81393c9171ae84193f1a9b5830d8a manifest.json+068ba1c5f8fbc2ea62b2df754c726526b343d8f7e23a1dc67b74e0c0faab754c manifest.jsonafd25df141b5e05dfa5c8848e1685a4e8b81f3c80fbafc4769c944b815356069 registries/literals.jsonc62900e74546b28a29b0883f4863536846d34b19159f3a8ca8bc0914218dfaa3 rules/response_presence.json74e43ed13dbfd578bcb8eedc5a247917788b320829b888eab84ce1126841d63b schemas/config.schema.json@@ -69,3 +70,4 @@ a0ec9be52e5ff9b83751283efd10ff071dc62ac90062d34b71594b37261dba8b schemas/manage9aafe3c28785298bbc143e170881df43866d1b6f1070f685cbdf3d6e4418f361 schemas/management_warning.schema.json3e51e0fad046fd9cd829d76d83b26bb6cd0b26be7a26ba223946ec92dcd7c6ce schemas/v1_evaluation.schema.json26925201a00b4605df0475091dd292fdc8dcc3c8fb05c23fee1c29ec2aec798a schemas/v2_boolean_evaluation.schema.json+f6ec83560301643532a2f36936d0cc3b9abb873cb7edaadcf71a6ec4a559dcc3 schemas/v2_value_evaluation.schema.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SOURCE.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SOURCE.jsonsimilarity index 62%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SOURCE.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SOURCE.jsonindex 37f6f4edcbd0..f9f55e2d3264 100644--- a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/SOURCE.json+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/SOURCE.json@@ -1,22 +1,25 @@{"source_repository": "https://github.com/PostHog/posthog-sdk-test-harness",- "source_revision": "6054eaa7972980ceb3b991f9535b488880978ddc",+ "source_revision": "32c8e08d36e20a5450fdcdd6ee80e2bdfd857a0a","release_status": "released",- "contract_version": "2.2.0",+ "contract_version": "2.3.0","v2_boolean_evaluation_version": "1.0.0",+ "v2_value_evaluation_version": "1.0.0","v1_corpus_version": "1.1.0","registry_version": "2.0.0","config_schema_version": "1.0.0",- "source_sha256sums_digest": "6aa00e4879408ce245829ab0fa40d8abb8f520a0456a190a56f193b37c45db09",+ "source_sha256sums_digest": "9c1b081e8a2097d8727da4cbbbb6aa2beb53de8f17daf112df01855dc9cbac69","files": ["README.md","manifest.json","registries/literals.json","schemas/config.schema.json","schemas/v2_boolean_evaluation.schema.json",- "corpus/v2_boolean_evaluation.json"+ "corpus/v2_boolean_evaluation.json",+ "schemas/v2_value_evaluation.schema.json",+ "corpus/v2_value_evaluation.json"],"vendoring_scope": "subset","upstream_metadata": "README.md, manifest.json, and SHA256SUMS describe the full upstream package. Only the paths in files and the source checksum index are vendored here, unchanged.",- "source_release": "1.8.0"+ "source_release": "1.13.0"}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/corpus/v2_boolean_evaluation.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/corpus/v2_boolean_evaluation.jsonsimilarity index 100%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/corpus/v2_boolean_evaluation.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/corpus/v2_boolean_evaluation.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/corpus/v2_value_evaluation.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/corpus/v2_value_evaluation.jsonnew file mode 100644index 000000000000..c48e40782323--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/corpus/v2_value_evaluation.json@@ -0,0 +1,3080 @@+{+ "corpus_version": "1.0.0",+ "config_version": 2,+ "description": "Person string, number and object ordered evaluation with the legacy rendering of each result. Expected terminal fields and legacy cells are exhaustive. Parser rows run at the parser boundary.",+ "cases": [+ {+ "id": "v2_value.string.target",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "compact"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "compact",+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "compact",+ "value": "compact",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.rollout_hit",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": "compact",+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "compact",+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "compact",+ "value": "compact",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.miss_return_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": "compact",+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "wide"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "standard",+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "standard",+ "value": "standard",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.miss_return_default_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": "compact",+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "wide"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.string.miss_continue",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": "compact",+ "rollout_percentage": 0,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "wide"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "wide",+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "wide",+ "value": "wide",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.no_match_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": "compact"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "standard",+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": true,+ "variant": "standard",+ "value": "standard",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.no_match_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": "compact"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.string.order_first_match",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": "compact"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "wide"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "compact",+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "compact",+ "value": "compact",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.order_targeting_miss",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": "compact"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": "wide"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "wide",+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "wide",+ "value": "wide",+ "payload": null+ }+ },+ {+ "id": "v2_value.number.target",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 1.25+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 1.25,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 1.25+ }+ },+ {+ "id": "v2_value.number.rollout_hit",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": 1.25,+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 1.25,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 1.25+ }+ },+ {+ "id": "v2_value.number.miss_return_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": 1.25,+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -40+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 0,+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 0+ }+ },+ {+ "id": "v2_value.number.miss_return_default_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": 1.25,+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -40+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.number.miss_continue",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": 1.25,+ "rollout_percentage": 0,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -40+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": -40,+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": -40+ }+ },+ {+ "id": "v2_value.number.no_match_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": 1.25+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 0,+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 0+ }+ },+ {+ "id": "v2_value.number.no_match_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": 1.25+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.number.order_first_match",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": 1.25+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -40+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 1.25,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 1.25+ }+ },+ {+ "id": "v2_value.number.order_targeting_miss",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": 1.25+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": -40+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": -40,+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": -40+ }+ },+ {+ "id": "v2_value.object.target",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ },+ {+ "id": "v2_value.object.rollout_hit",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "rollout_percentage": 100,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ },+ {+ "id": "v2_value.object.miss_return_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "wide"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "standard"+ },+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "standard"+ }+ }+ },+ {+ "id": "v2_value.object.miss_return_default_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "rollout_percentage": 0,+ "on_rollout_miss": "return_default",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "wide"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "rollout_miss",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "index": 0+ }+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.object.miss_continue",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "percentage_rollout",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "rollout_percentage": 0,+ "on_rollout_miss": "continue",+ "assignment_algorithm": "sha1_60_v1",+ "seed": "example-allocation",+ "assign_by": "person"+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "wide"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "wide"+ },+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "wide"+ }+ }+ },+ {+ "id": "v2_value.object.no_match_default",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "standard"+ },+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "standard"+ }+ }+ },+ {+ "id": "v2_value.object.no_match_null",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": null,+ "reason": "no_rule_match"+ },+ "legacy": {+ "enabled": false,+ "variant": null,+ "value": false,+ "payload": null+ }+ },+ {+ "id": "v2_value.object.order_first_match",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "wide"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ },+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ }+ },+ {+ "id": "v2_value.object.order_targeting_miss",+ "family": "ordering",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": {+ "layout": "standard"+ },+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "free"+ ],+ "negation": false+ }+ ]+ },+ "value": {+ "layout": "compact",+ "options": [+ 1,+ true,+ null+ ]+ }+ },+ {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": [+ {+ "key": "plan",+ "type": "person",+ "operator": "exact",+ "value": [+ "pro"+ ],+ "negation": false+ }+ ]+ },+ "value": {+ "layout": "wide"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "layout": "wide"+ },+ "reason": "targeting_match",+ "rule": {+ "id": "22222222-2222-4222-8222-222222222222",+ "rule_type": "targeted_release",+ "index": 1+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "layout": "wide"+ }+ }+ },+ {+ "id": "v2_value.string.unicode",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "Grüße 👋"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "Grüße 👋",+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "Grüße 👋",+ "value": "Grüße 👋",+ "payload": null+ }+ },+ {+ "id": "v2_value.string.looks_boolean",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "false"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": "false",+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": "false",+ "value": "false",+ "payload": null+ }+ },+ {+ "id": "v2_value.number.zero",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 0+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 0,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 0+ }+ },+ {+ "id": "v2_value.number.negative_decimal",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -2.5+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": -2.5,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": -2.5+ }+ },+ {+ "id": "v2_value.number.short_decimal",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 0.1+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 0.1,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 0.1+ }+ },+ {+ "id": "v2_value.number.exponent",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 1.5e-07+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 1.5e-07,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 1.5e-07+ }+ },+ {+ "id": "v2_value.number.max_safe_integer",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 9007199254740991+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": 9007199254740991,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": 9007199254740991+ }+ },+ {+ "id": "v2_value.number.min_safe_integer",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -9007199254740991+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": -9007199254740991,+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": -9007199254740991+ }+ },+ {+ "id": "v2_value.object.empty",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {}+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {},+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {}+ }+ },+ {+ "id": "v2_value.object.nested",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "theme": {+ "colors": [+ "#000000",+ "#ffffff"+ ],+ "radius": 4.5+ },+ "flags": [+ true,+ false,+ null+ ],+ "label": "Ünïcode"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "theme": {+ "colors": [+ "#000000",+ "#ffffff"+ ],+ "radius": 4.5+ },+ "flags": [+ true,+ false,+ null+ ],+ "label": "Ünïcode"+ },+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "theme": {+ "colors": [+ "#000000",+ "#ffffff"+ ],+ "radius": 4.5+ },+ "flags": [+ true,+ false,+ null+ ],+ "label": "Ünïcode"+ }+ }+ },+ {+ "id": "v2_value.object.max_depth",+ "family": "values",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "leaf": true+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "success",+ "value": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "leaf": true+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ },+ "reason": "targeting_match",+ "rule": {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "index": 0+ }+ },+ "legacy": {+ "enabled": true,+ "variant": null,+ "value": true,+ "payload": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "leaf": true+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ },+ {+ "id": "v2_value.parser.string_empty_value",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": ""+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.string_empty_default",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "compact"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.string_value_mismatch",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "string",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": true+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.number_value_mismatch",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": "1.25"+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.number_default_mismatch",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": true,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 1.25+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.number_above_safe_integer",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": 9007199254740992.0+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.number_below_safe_integer",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "number",+ "default_value": 0,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": -9007199254740992.0+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.object_array_value",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": [+ {+ "layout": "compact"+ }+ ]+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.object_default_mismatch",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": "standard",+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "layout": "compact"+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.object_too_deep",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "child": {+ "leaf": true+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ },+ {+ "id": "v2_value.parser.object_nested_number_above_safe_integer",+ "family": "parser",+ "flag": {+ "key": "example-display-key",+ "name": "Example display name",+ "active": true,+ "deleted": false,+ "requested": true+ },+ "config": {+ "version": 2,+ "return_type": "object",+ "default_value": null,+ "rules": [+ {+ "id": "11111111-1111-4111-8111-111111111111",+ "rule_type": "targeted_release",+ "targeting": {+ "properties": []+ },+ "value": {+ "limit": 9007199254740992.0+ }+ }+ ]+ },+ "context": {+ "identifier": "person-example",+ "properties": {+ "plan": "pro"+ },+ "properties_complete": true,+ "timezone": "UTC",+ "explicit_exact_matching": true,+ "now": "2024-03-31T12:00:00Z"+ },+ "expected": {+ "status": "parse_error",+ "kind": "malformed"+ }+ }+ ]+}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/manifest.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/manifest.jsonsimilarity index 94%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/manifest.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/manifest.jsonindex 59789252294d..76d246d52ab2 100644--- a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/manifest.json+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/manifest.json@@ -2,7 +2,7 @@"manifest_version": 1,"contract": {"name": "feature_flag_rules_v2",- "version": "2.2.0",+ "version": "2.3.0","config_version": 2},"corpus": {@@ -1177,6 +1177,69 @@"v2_boolean.error.invalid_not_regex_negated","v2_boolean.target.empty_identifier"]+ },+ {+ "path": "schemas/v2_value_evaluation.schema.json",+ "kind": "schema",+ "version": "1.0.0"+ },+ {+ "path": "corpus/v2_value_evaluation.json",+ "kind": "value_evaluation_corpus",+ "version": "1.0.0",+ "schema": "schemas/v2_value_evaluation.schema.json",+ "component": "v2_value_evaluation",+ "case_ids": [+ "v2_value.string.target",+ "v2_value.string.rollout_hit",+ "v2_value.string.miss_return_default",+ "v2_value.string.miss_return_default_null",+ "v2_value.string.miss_continue",+ "v2_value.string.no_match_default",+ "v2_value.string.no_match_null",+ "v2_value.string.order_first_match",+ "v2_value.string.order_targeting_miss",+ "v2_value.number.target",+ "v2_value.number.rollout_hit",+ "v2_value.number.miss_return_default",+ "v2_value.number.miss_return_default_null",+ "v2_value.number.miss_continue",+ "v2_value.number.no_match_default",+ "v2_value.number.no_match_null",+ "v2_value.number.order_first_match",+ "v2_value.number.order_targeting_miss",+ "v2_value.object.target",+ "v2_value.object.rollout_hit",+ "v2_value.object.miss_return_default",+ "v2_value.object.miss_return_default_null",+ "v2_value.object.miss_continue",+ "v2_value.object.no_match_default",+ "v2_value.object.no_match_null",+ "v2_value.object.order_first_match",+ "v2_value.object.order_targeting_miss",+ "v2_value.string.unicode",+ "v2_value.string.looks_boolean",+ "v2_value.number.zero",+ "v2_value.number.negative_decimal",+ "v2_value.number.short_decimal",+ "v2_value.number.exponent",+ "v2_value.number.max_safe_integer",+ "v2_value.number.min_safe_integer",+ "v2_value.object.empty",+ "v2_value.object.nested",+ "v2_value.object.max_depth",+ "v2_value.parser.string_empty_value",+ "v2_value.parser.string_empty_default",+ "v2_value.parser.string_value_mismatch",+ "v2_value.parser.number_value_mismatch",+ "v2_value.parser.number_default_mismatch",+ "v2_value.parser.number_above_safe_integer",+ "v2_value.parser.number_below_safe_integer",+ "v2_value.parser.object_array_value",+ "v2_value.parser.object_default_mismatch",+ "v2_value.parser.object_too_deep",+ "v2_value.parser.object_nested_number_above_safe_integer"+ ]}],"wire_contract": {@@ -1191,5 +1254,10 @@"version": "1.0.0","config_version_locked": 2,"published_versions_are_immutable": true+ },+ "v2_value_evaluation": {+ "version": "1.0.0",+ "config_version_locked": 2,+ "published_versions_are_immutable": true}}diff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/registries/literals.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/registries/literals.jsonsimilarity index 100%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/registries/literals.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/registries/literals.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/schemas/config.schema.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/config.schema.jsonsimilarity index 100%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/schemas/config.schema.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/config.schema.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/schemas/v2_boolean_evaluation.schema.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/v2_boolean_evaluation.schema.jsonsimilarity index 100%rename from rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.2.0/schemas/v2_boolean_evaluation.schema.jsonrename to rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/v2_boolean_evaluation.schema.jsondiff --git a/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/v2_value_evaluation.schema.json b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/v2_value_evaluation.schema.jsonnew file mode 100644index 000000000000..5225c84c6880--- /dev/null+++ b/rust/feature-flags/tests/fixtures/rules_v2_evaluation/2.3.0/schemas/v2_value_evaluation.schema.json@@ -0,0 +1,290 @@+{+ "$schema": "https://json-schema.org/draft/2020-12/schema",+ "$id": "urn:posthog:feature-flag-rules-v2:corpus:v2_value_evaluation:1.0.0",+ "type": "object",+ "properties": {+ "corpus_version": {+ "const": "1.0.0"+ },+ "config_version": {+ "const": 2+ },+ "description": {+ "type": "string"+ },+ "cases": {+ "type": "array",+ "minItems": 1,+ "items": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "pattern": "^v2_value(\\.[a-z0-9_]+)+$"+ },+ "family": {+ "enum": [+ "ordering",+ "values",+ "parser"+ ]+ },+ "flag": {+ "type": "object",+ "properties": {+ "key": {+ "type": "string"+ },+ "name": {+ "type": "string"+ },+ "active": {+ "const": true+ },+ "deleted": {+ "const": false+ },+ "requested": {+ "const": true+ }+ },+ "required": [+ "key",+ "name",+ "active",+ "deleted",+ "requested"+ ],+ "additionalProperties": false+ },+ "config": {+ "type": "object",+ "properties": {+ "return_type": {+ "enum": [+ "string",+ "number",+ "object"+ ]+ }+ },+ "required": [+ "return_type"+ ],+ "additionalProperties": true,+ "x-posthog-open-object": "validated separately against the canonical config schema, including rejected examples"+ },+ "context": {+ "type": "object",+ "properties": {+ "identifier": {+ "type": "string",+ "minLength": 1+ },+ "properties": {+ "type": "object",+ "additionalProperties": true,+ "x-posthog-open-object": "supplied person property values"+ },+ "properties_complete": {+ "const": true+ },+ "timezone": {+ "type": "string"+ },+ "explicit_exact_matching": {+ "type": "boolean"+ },+ "now": {+ "type": "string",+ "format": "date-time"+ }+ },+ "required": [+ "identifier",+ "properties",+ "properties_complete",+ "timezone",+ "explicit_exact_matching",+ "now"+ ],+ "additionalProperties": false+ },+ "expected": {+ "oneOf": [+ {+ "type": "object",+ "properties": {+ "status": {+ "const": "success"+ },+ "value": {+ "type": [+ "string",+ "number",+ "object",+ "null"+ ]+ },+ "reason": {+ "enum": [+ "targeting_match",+ "rollout_miss",+ "no_rule_match"+ ]+ },+ "rule": {+ "type": "object",+ "properties": {+ "id": {+ "type": "string",+ "format": "uuid"+ },+ "rule_type": {+ "enum": [+ "targeted_release",+ "percentage_rollout"+ ]+ },+ "index": {+ "type": "integer",+ "minimum": 0+ }+ },+ "required": [+ "id",+ "rule_type",+ "index"+ ],+ "additionalProperties": false+ }+ },+ "required": [+ "status",+ "value",+ "reason"+ ],+ "if": {+ "properties": {+ "reason": {+ "const": "no_rule_match"+ }+ }+ },+ "then": {+ "not": {+ "required": [+ "rule"+ ]+ }+ },+ "else": {+ "required": [+ "rule"+ ]+ },+ "additionalProperties": false+ },+ {+ "type": "object",+ "properties": {+ "status": {+ "const": "parse_error"+ },+ "kind": {+ "const": "malformed"+ }+ },+ "required": [+ "status",+ "kind"+ ],+ "additionalProperties": false+ }+ ]+ },+ "legacy": {+ "type": "object",+ "description": "Legacy rendering of expected.value. enabled is the detailed record's enabled field and decides inclusion in the enabled-only maps and lists; variant is the detailed record's variant; value is the flag map entry; payload is the decoded JSON-encoded payload string, or null for no payload.",+ "properties": {+ "enabled": {+ "type": "boolean"+ },+ "variant": {+ "type": [+ "string",+ "null"+ ],+ "minLength": 1+ },+ "value": {+ "anyOf": [+ {+ "type": "boolean"+ },+ {+ "type": "string",+ "minLength": 1+ }+ ]+ },+ "payload": {+ "type": [+ "number",+ "object",+ "null"+ ]+ }+ },+ "required": [+ "enabled",+ "variant",+ "value",+ "payload"+ ],+ "additionalProperties": false+ }+ },+ "required": [+ "id",+ "family",+ "flag",+ "config",+ "context",+ "expected"+ ],+ "if": {+ "properties": {+ "expected": {+ "properties": {+ "status": {+ "const": "success"+ }+ }+ }+ }+ },+ "then": {+ "required": [+ "legacy"+ ]+ },+ "else": {+ "not": {+ "required": [+ "legacy"+ ]+ }+ },+ "additionalProperties": false+ }+ }+ },+ "required": [+ "corpus_version",+ "config_version",+ "description",+ "cases"+ ],+ "additionalProperties": false+}diff --git a/rust/feature-flags/tests/test_config_v2.rs b/rust/feature-flags/tests/test_config_v2.rsindex c2093ede83dc..fb19fe9b4d13 100644--- a/rust/feature-flags/tests/test_config_v2.rs+++ b/rust/feature-flags/tests/test_config_v2.rs@@ -1,6 +1,8 @@use std::sync::Arc;-use feature_flags::flags::config_v2::{Config, Outcome, ParseError, RolloutMiss, MAX_CONFIG_BYTES};+use feature_flags::flags::config_v2::{+ Config, Outcome, ParseError, RolloutMiss, MAX_CONFIG_BYTES, MAX_OBJECT_DEPTH,+};use feature_flags::flags::feature_flag_list::PreparedFlags;use feature_flags::flags::flag_models::{EvaluationMetadata, FeatureFlag, FeatureFlagRow, HypercacheFlagsWrapper,@@ -202,7 +204,10 @@ fn supported_values_and_order_survive_the_reader() {}));let flag = read(document.clone());let parsed = result(&flag).as_ref().unwrap();- assert_eq!(parsed.default_value, default.as_bool());+ assert_eq!(+ parsed.default_value,+ (!default.is_null()).then(|| default.clone())+ );assert_eq!(parsed.rules.len(), 2);assert_eq!(parsed.rules[0].id.to_string(), document["rules"][0]["id"]);match &parsed.rules[0].outcome {@@ -212,7 +217,7 @@ fn supported_values_and_order_survive_the_reader() {on_rollout_miss,seed,} => {- assert!(*value);+ assert_eq!(*value, json!(true));assert_eq!(*rollout_percentage, percentage);assert_eq!(*on_rollout_miss,@@ -228,7 +233,9 @@ fn supported_values_and_order_survive_the_reader() {}assert!(matches!(parsed.rules[1].outcome,- Outcome::TargetedRelease { value: false }+ Outcome::TargetedRelease {+ value: Value::Bool(false)+ }));assert_eq!(serde_json::to_value(&flag).unwrap()["filters"], document);}@@ -403,6 +410,33 @@ fn semantic_limits_and_duplicate_ids_are_enforced() {result(&read(document)).as_ref().unwrap_err(),&ParseError::LimitExceeded("filters"));++ // Arrays count toward the object depth, and numbers inside them keep the safe range.+ let mut deepest = json!("leaf");+ for _ in 1..MAX_OBJECT_DEPTH {+ deepest = json!([deepest]);+ }+ for (value, accepted) in [+ (json!({"list": deepest.clone()}), true),+ (json!({"list": [deepest]}), false),+ (json!({"limits": [9_007_199_254_740_991_u64]}), true),+ (json!({"limits": [9_007_199_254_740_992_u64]}), false),+ (json!({"limits": [-9_007_199_254_740_992_i64]}), false),+ ] {+ let mut document = config();+ document["return_type"] = json!("object");+ document["default_value"] = Value::Null;+ document["rules"][0]["value"] = value;+ let flag = read(document);+ if accepted {+ assert!(result(&flag).is_ok());+ } else {+ assert_eq!(+ result(&flag).as_ref().unwrap_err(),+ &ParseError::Malformed("value")+ );+ }+ }}fn person_property_cases() -> Vec<(&'static str, Value)> {@@ -539,19 +573,12 @@ fn unsupported_members_reject_the_whole_flag_and_debug_redacts_config() {&ParseError::Unsupported("property.type"));}- for (field, value) in [- ("return_type", json!("string")),- ("return_type", json!("number")),- ("return_type", json!("object")),- ("aggregation_group_type_index", json!(0)),- ] {- let mut document = config();- document[field] = value;- assert!(matches!(- result(&read(document)),- Err(ParseError::Unsupported(_))- ));- }+ let mut document = config();+ document["aggregation_group_type_index"] = json!(0);+ assert_eq!(+ result(&read(document)).as_ref().unwrap_err(),+ &ParseError::Unsupported("aggregation_group_type_index")+ );let mut document = config();document["rules"].as_array_mut()@@ -643,4 +670,15 @@ fn preparation_reuses_parsing_and_accounts_for_raw_and_typed_data() {assert!(result(&flag).is_ok());let weighted = prepared(flag).estimated_size_bytes();assert!(weighted > document.to_string().len() + 50_000 * std::mem::size_of::<Value>());++ // The parsed default and each rule value count, not only their raw text.+ let object = json!({"items": vec![Value::Null; 1000]});+ let mut document = config();+ document["return_type"] = json!("object");+ document["default_value"] = object.clone();+ document["rules"][0]["value"] = object;+ let flag = read(document.clone());+ assert!(result(&flag).is_ok());+ let weighted = prepared(flag).estimated_size_bytes();+ assert!(weighted > document.to_string().len() + 2000 * std::mem::size_of::<Value>());}diff --git a/rust/feature-flags/tests/test_config_v2/fixtures.rs b/rust/feature-flags/tests/test_config_v2/fixtures.rsindex d47065385395..4adfe044a74d 100644--- a/rust/feature-flags/tests/test_config_v2/fixtures.rs+++ b/rust/feature-flags/tests/test_config_v2/fixtures.rs@@ -76,8 +76,15 @@ fn released_config_cases_distinguish_schema_expectations_from_supported_familieslet flag = read(document.clone());let parsed = flag.filters.non_v1.as_ref().unwrap().parsed_v2.as_ref();if fixture["expected"] == "valid" {- if path.ends_with("version_float_literal.json")- || path.ends_with("boolean_targeted_and_percentage_rollout.json")+ if [+ "version_float_literal.json",+ "boolean_targeted_and_percentage_rollout.json",+ "reserved_number_value.json",+ "reserved_object_value.json",+ "object_value_max_depth.json",+ ]+ .iter()+ .any(|name| path.ends_with(name)){assert!(parsed.unwrap().is_ok(), "{path}: {parsed:?}");totals.supported += 1;@@ -124,10 +131,10 @@ fn released_config_cases_distinguish_schema_expectations_from_supported_familiesassert_eq!(totals,Totals {- supported: 2,- valid_but_unsupported: 6,- malformed: 18,- unsupported: 11,+ supported: 5,+ valid_but_unsupported: 3,+ malformed: 20,+ unsupported: 9,rejected_before_parsing: 3,});@@ -141,7 +148,10 @@ fn invalid_fixture_error(name: &str) -> Option<ParseError> {"empty_seed" | "missing_rollout_seed" => Malformed("seed"),"missing_on_rollout_miss" => Malformed("on_rollout_miss"),"non_uuid_rule_id" => Malformed("rule.id"),- "null_rule_value" | "return_value_type_mismatch" => Malformed("value"),+ "null_rule_value"+ | "return_value_type_mismatch"+ | "empty_string_value"+ | "object_value_too_deep" => Malformed("value"),"rollout_percentage_above_maximum" | "rollout_percentage_below_minimum" => {Malformed("rollout_percentage")}@@ -152,7 +162,6 @@ fn invalid_fixture_error(name: &str) -> Option<ParseError> {"unknown_property_operator" => Malformed("property.operator"),"unknown_property_type" => Malformed("property.type"),"unknown_rollout_miss_policy" => Malformed("on_rollout_miss"),- "empty_string_value" | "object_value_too_deep" => Unsupported("return_type"),"group_experiment_with_assign_by" | "group_percentage_rollout_with_assign_by" => {Unsupported("aggregation_group_type_index")}@@ -184,6 +193,8 @@ fn repair_supported_fixture(name: &str, mut document: Value) -> Value {"null_rule_value" | "return_value_type_mismatch" => {document["rules"][0]["value"] = json!(false)}+ "empty_string_value" => document["rules"][0]["value"] = json!("compact"),+ "object_value_too_deep" => document["rules"][0]["value"] = json!({}),"rollout_percentage_above_maximum" | "rollout_percentage_below_minimum" => {document["rules"][0]["rollout_percentage"] = json!(33.33)}@@ -405,18 +416,20 @@ fn released_schema_and_registry_match_the_parser_contract() {assert!(result(&flag).is_ok());}}- for entry in registry["return_types"].as_array().unwrap() {+ let return_types = registry["return_types"].as_array().unwrap();+ let samples = [+ json!(true),+ json!("compact"),+ json!(1.25),+ json!({"layout": "compact"}),+ ];+ assert_eq!(return_types.len(), samples.len());+ for (entry, value) in return_types.iter().zip(samples) {let mut document = config();document["return_type"] = entry["value"].clone();- let flag = read(document);- if entry["value"] == "boolean" {- assert!(result(&flag).is_ok());- } else {- assert_eq!(- result(&flag).as_ref().unwrap_err(),- &ParseError::Unsupported("return_type")- );- }+ document["default_value"] = Value::Null;+ document["rules"][0]["value"] = value;+ assert!(result(&read(document)).is_ok(), "{entry}");}for entry in registry["rule_types"].as_array().unwrap() {let mut document = config();diff --git a/rust/feature-flags/tests/test_rules_v2_evaluation.rs b/rust/feature-flags/tests/test_rules_v2_evaluation.rsindex 52b66cbe86b2..2a77799cf9a7 100644--- a/rust/feature-flags/tests/test_rules_v2_evaluation.rs+++ b/rust/feature-flags/tests/test_rules_v2_evaluation.rs@@ -21,7 +21,7 @@ fn pinned_evaluation_artifact_subset_is_intact() {assert_eq!(revision.len(), 40);assert!(revision.bytes().all(|c| c.is_ascii_hexdigit()));assert_eq!(source["release_status"], "released");- assert_eq!(source["source_release"], "1.8.0");+ assert_eq!(source["source_release"], "1.13.0");let index = std::fs::read(corpus::root().join("SHA256SUMS")).unwrap();assert_eq!(hex::encode(Sha256::digest(&index)),@@ -51,41 +51,51 @@ fn pinned_evaluation_artifact_subset_is_intact() {}let manifest = corpus::load("manifest.json");assert_eq!(manifest["contract"]["version"], source["contract_version"]);- assert_eq!(- manifest["v2_boolean_evaluation"]["version"],- source["v2_boolean_evaluation_version"]- );- let cases = corpus::cases();- let ids: Vec<_> = cases.iter().map(|case| case["id"].clone()).collect();- let artifact = manifest["artifacts"]- .as_array()- .unwrap()- .iter()- .find(|artifact| artifact["path"] == "corpus/v2_boolean_evaluation.json")- .unwrap();- assert_eq!(json!(ids), artifact["case_ids"]);- assert_eq!(- ids.iter()- .map(Value::to_string)- .collect::<BTreeSet<_>>()- .len(),- ids.len()- );let mut counts = BTreeMap::new();- for case in &cases {- *counts.entry(case["family"].as_str().unwrap()).or_insert(0) += 1;+ for (component, cases) in [+ ("v2_boolean_evaluation", corpus::cases()),+ ("v2_value_evaluation", corpus::value_cases()),+ ] {+ assert_eq!(+ manifest[component]["version"],+ source[format!("{component}_version")]+ );+ let ids: Vec<_> = cases.iter().map(|case| case["id"].clone()).collect();+ let artifact = manifest["artifacts"]+ .as_array()+ .unwrap()+ .iter()+ .find(|artifact| artifact["path"] == format!("corpus/{component}.json"))+ .unwrap();+ assert_eq!(json!(ids), artifact["case_ids"]);+ assert_eq!(+ ids.iter()+ .map(Value::to_string)+ .collect::<BTreeSet<_>>()+ .len(),+ ids.len()+ );+ for case in &cases {+ *counts+ .entry((component, case["family"].as_str().unwrap().to_owned()))+ .or_insert(0) += 1;+ }}+ let family = |component, family: &str, count| ((component, family.to_owned()), count);assert_eq!(counts,BTreeMap::from([- ("ordering", 18),- ("properties", 67),- ("context", 8),- ("errors", 6),- ("hashing", 21),- ("white_box", 10),- ("eligibility", 3),- ("parser", 2),+ family("v2_boolean_evaluation", "ordering", 18),+ family("v2_boolean_evaluation", "properties", 67),+ family("v2_boolean_evaluation", "context", 8),+ family("v2_boolean_evaluation", "errors", 6),+ family("v2_boolean_evaluation", "hashing", 21),+ family("v2_boolean_evaluation", "white_box", 10),+ family("v2_boolean_evaluation", "eligibility", 3),+ family("v2_boolean_evaluation", "parser", 2),+ family("v2_value_evaluation", "ordering", 27),+ family("v2_value_evaluation", "values", 11),+ family("v2_value_evaluation", "parser", 11),]));}@@ -94,11 +104,11 @@ fn pinned_evaluation_artifact_subset_is_intact() {fn parsed_configs_match_every_core_case_without_mutating_cached_inputs() {let mut executed = 0;let mut rejected = 0;- for case in corpus::cases() {+ for case in corpus::cases().into_iter().chain(corpus::value_cases()) {let id = case["id"].as_str().unwrap();match case["family"].as_str().unwrap() {"white_box" | "eligibility" => continue,- "ordering" | "properties" | "context" | "errors" | "hashing" | "parser" => {}+ "ordering" | "properties" | "context" | "errors" | "hashing" | "values" | "parser" => {}other => panic!("unhandled family: {other}"),}let flag = corpus::read(&case);@@ -171,7 +181,7 @@ fn parsed_configs_match_every_core_case_without_mutating_cached_inputs() {}executed += 1;}- assert_eq!((executed, rejected), (120, 2));+ assert_eq!((executed, rejected), (120 + 38, 2 + 11));}#[tokio::test]@@ -402,7 +412,7 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {None,));let (mut projected, mut direct, mut skipped) = (0, 0, 0);- for case in corpus::cases() {+ for case in corpus::cases().into_iter().chain(corpus::value_cases()) {let id = case["id"].as_str().unwrap();let properties = corpus::properties(&case);let context = corpus::context(&case, &properties);@@ -431,7 +441,18 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {.with_now(context.now);let expected = &case["expected"];let failed = expected["status"] != "success";- let enabled = expected["value"].as_bool().unwrap_or(false);+ let legacy = case.get("legacy").cloned().unwrap_or_else(|| {+ let enabled = expected["value"].as_bool().unwrap_or(false);+ json!({"enabled": enabled, "variant": null, "value": enabled, "payload": null})+ });+ let enabled = legacy["enabled"].as_bool().unwrap();+ let variant = legacy["variant"].as_str().map(str::to_owned);+ let payload = Some(&legacy["payload"]).filter(|payload| !payload.is_null());+ let decoded = |payload: &Option<Value>| {+ payload+ .as_ref()+ .map(|p| serde_json::from_str::<Value>(p.as_str().unwrap()).unwrap())+ };let reason = match expected["reason"].as_str() {Some("targeting_match") => "condition_match",Some("rollout_miss") => "out_of_rollout_bound",@@ -453,7 +474,11 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {(enabled, reason.to_string(), rule_index.map(|i| i as usize)),"{id}");- assert_eq!((outcome.variant, outcome.payload), (None, None), "{id}");+ assert_eq!(+ (outcome.variant, decoded(&outcome.payload).as_ref()),+ (variant, payload),+ "{id}"+ );}Err(error) => {assert!(failed, "{id}");@@ -495,9 +520,9 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {details.failed,details.enabled,&details.variant,- &details.metadata.payload+ decoded(&details.metadata.payload).as_ref()),- (failed, enabled, &None, &None),+ (failed, enabled, &variant, payload),"{id}");assert_eq!(response.errors_while_computing_flags, failed, "{id}");@@ -518,13 +543,14 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {}let wire = serde_json::to_value(&response).unwrap();let reparse = || serde_json::from_value::<FlagsResponse>(wire.clone()).unwrap();- let legacy = LegacyFlagsResponse::from_response(reparse());+ let map_value: FlagValue = serde_json::from_value(legacy["value"].clone()).unwrap();+ let flags_v1 = LegacyFlagsResponse::from_response(reparse());+ assert_eq!(flags_v1.feature_flags[&key], map_value, "{id}");assert_eq!(- legacy.feature_flags[&key],- FlagValue::Boolean(enabled),+ decoded(&flags_v1.feature_flag_payloads.get(&key).cloned()).as_ref(),+ payload,"{id}");- assert!(legacy.feature_flag_payloads.is_empty(), "{id}");assert_eq!(DecideV1Response::from_response(reparse()).feature_flags@@ -536,10 +562,10 @@ async fn corpus_cases_project_through_the_matcher_and_the_legacy_formats() {DecideV2Response::from_response(reparse()).feature_flags.get(&key),- enabled.then_some(FlagValue::Boolean(true)).as_ref(),+ enabled.then_some(map_value).as_ref(),"{id}");projected += 1;}- assert_eq!((projected, direct, skipped), (114, 8, 13));+ assert_eq!((projected, direct, skipped), (114 + 49, 8, 13));}diff --git a/rust/feature-flags/tests/test_rules_v2_evaluation/corpus.rs b/rust/feature-flags/tests/test_rules_v2_evaluation/corpus.rsindex 828beb6a3eaf..f1ee29966ef2 100644--- a/rust/feature-flags/tests/test_rules_v2_evaluation/corpus.rs+++ b/rust/feature-flags/tests/test_rules_v2_evaluation/corpus.rs@@ -9,7 +9,7 @@ use feature_flags::flags::flag_models::FeatureFlag;use serde_json::{json, Value};pub fn root() -> PathBuf {- PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/rules_v2_evaluation/2.2.0")+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/rules_v2_evaluation/2.3.0")}pub fn load(path: &str) -> Value {@@ -23,6 +23,13 @@ pub fn cases() -> Vec<Value> {.clone()}+pub fn value_cases() -> Vec<Value> {+ load("corpus/v2_value_evaluation.json")["cases"]+ .as_array()+ .unwrap()+ .clone()+}+pub fn read(case: &Value) -> FeatureFlag {serde_json::from_value(json!({"id": 1, "team_id": 1, "key": case["flag"]["key"], "name": case["flag"]["name"],