Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/understand/scenarios/parametric.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ Use `mocked_backend.client.ffe_set_response` or `mocked_backend.client.ffe_set_r

The protobuf response IDs `selection_ignored_empty`, `selection_ignored_tag_load_failed`, and `selection_ignored_unknown` return the full rules fixture with a `DD-Flag-Selection-Ignored` header set to an empty string, `tag_load_failed`, or `future_reason`, respectively. Use these shared responses to test selection diagnostics without replacing the rules endpoint handler. The `valid` response omits the header.

#### Standalone Precomputation

`test_library.ffe_precompute_configuration(payload)` calls `POST /ffe/precompute-configuration` (Node.js only). It starts a fresh process without tracer/provider initialization and calls the public `dd-trace/openfeature/rules-based` helpers. Supply either a serialized `wire` or `fetchOptions` (using the same custom transport as the rules-fetch endpoint), an array of `contexts`, and optional precomputation `options`. One configuration is reused for every context. No browser is initialized.

Success returns `{ "results": [{ "wire": "...", "errors": [{ "flagKey": "...", "errorCode": "PARSE_ERROR" }] }], "httpRequests": 0, "exposureEvents": 0 }`. The error array contains omitted-flag diagnostics. Expected input/fetch failures return an `error` object with `name`, `code`, and `message`, plus the same counters; unexpected failures return HTTP 500. Input validation failures expect zero requests. HTTP fetch failures expect one request and include `error.status`; successful fetching followed by precomputation also expects one request. Local conversion expects zero requests.

Counts observe Node's Undici/HTTP request diagnostics and the `ffe:exposure:submit` channel, from before import until child-process exit. They do not directly observe queued evaluation telemetry, which has no corresponding diagnostic channel.

#### Effective OpenTelemetry configuration

Use `test_library.otel_effective_config()` to inspect resolved OTLP exporter timeouts.
Expand Down
6 changes: 6 additions & 0 deletions docs/understand/weblogs/parametric_weblog.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,12 @@ Called by `ParametricTestClientApi.ffe_fetch_rules_configuration()`. Fetch and s
**Not implemented by the Python reference server**. The request body is the `options` object of the test: see
[Standalone Rules Configuration](../scenarios/parametric.md#standalone-rules-configuration).

#### `POST /ffe/precompute-configuration`

Called by `ParametricTestClientApi.ffe_precompute_configuration()`. Precompute portable rules for one or more contexts in a fresh process without tracer/provider initialization.

**Not implemented by the Python reference server**. See [Standalone Precomputation](../scenarios/parametric.md#standalone-precomputation) for the request payload, typed errors, and observed request/exposure counts. Input validation failures expect zero requests; HTTP fetch failures expect one request and include `error.status`.

#### `POST /ffe/start`

Called by `ParametricTestClientApi.ffe_start()`. Initialize the FFE (Feature Flagging & Experimentation) provider.
Expand Down
1 change: 1 addition & 0 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,7 @@ manifest:
tests/parametric/test_ffe/test_exposure_hooks.py: incomplete_test_app (Exposure hook observations are not implemented)
tests/parametric/test_ffe/test_flag_selection.py: *ref_6_25_0
tests/parametric/test_ffe/test_rules_configuration.py: 7.0.0-pre # Exact development version until the first containing release is confirmed.
tests/parametric/test_ffe/test_rules_configuration.py::Test_FFE_Rules_Configuration_Precompute: missing_feature (FFL-3536 requires the precomputation dependency and public exports in dd-trace-js)
tests/parametric/test_ffe/test_rules_configuration.py::Test_FFE_Rules_Configuration_Selection: missing_feature (FFL-3364 requires the Node flag-selection dependency update in dd-trace-js)
tests/parametric/test_ffe/test_serial_id_metadata.py: v6.18.0
tests/parametric/test_ffe/test_serial_id_metadata.py::Test_FFE_Serial_Id_Metadata_Go: irrelevant (Legacy Go metadata key)
Expand Down
10 changes: 8 additions & 2 deletions tests/ffe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ configuration copies are needed.

Standalone rules-configuration helpers are covered in `tests/parametric/test_ffe/test_rules_configuration.py` (Node.js only for now). These tests use `dd-trace/openfeature/rules-based` in a fresh process without initializing a tracer or provider, fetch protobuf over HTTP, and validate the portable wire output, channel credentials, typed errors, deadlines and cancellation during headers/body delivery, transport failures, invalid options, and redirect protection. They do not initialize a browser SDK or contact Datadog.

These tests report to [Offline initialization and portable configuration helpers (#562)](https://feature-parity.us1.prod.dog/?feature=562). Current coverage is limited to Node's rules-based fetching and serialization; precomputed helpers and provider offline initialization are not covered here.
These tests report to [Offline initialization and portable configuration helpers (#562)](https://feature-parity.us1.prod.dog/?feature=562). `Test_FFE_Rules_Configuration_Precompute` adds Node's local rules-to-precomputed conversion: context-specific assignments, metadata preservation, omitted failed/unassigned flags, sanitized input errors, and reuse of one fetch across multiple contexts. It observes Node HTTP diagnostics and the exposure channel through child-process exit to check that local precomputation adds no requests or exposure events. Queued evaluation telemetry is not directly observed. Provider offline initialization and browser handoff remain outside this coverage.

The precomputation class requires [openfeature-js-client #448](https://github.com/DataDog/openfeature-js-client/pull/448) plus the dependency and public exports in `dd-trace/openfeature/rules-based`. It remains gated in the Node manifest until a containing build is available; other SDKs retain the existing file-level gate.

To validate an unreleased build containing these changes, use the [custom Node tracer instructions](../../docs/execute/binaries.md#nodejs-library), select `tests/parametric/test_ffe/test_rules_configuration.py::Test_FFE_Rules_Configuration_Precompute`, and pass the same node ID to `-F`. The required new public exports are `configurationFromString`, `precomputeConfiguration`, and `ConfigurationPrecomputeError`. Once released, update the class gate and the existing file-level version restriction together.

`Test_FFE_Rules_Configuration_Selection` covers tag/key-pattern query parameters on both distribution channels, invalid/URL-overflow selections dropped with diagnostics, quiet empty-selection omission, and retention of the full response when the backend ignores selection. It also checks diagnostics for nonempty `DD-Flag-Selection-Ignored` response headers, including unknown reasons. The mock does not implement backend filtering. These cases require [openfeature-js-client #445](https://github.com/DataDog/openfeature-js-client/pull/445) in the `dd-trace` dependency and remain gated in the Node manifest until a containing build is available. Other SDKs retain the existing file-level gate.

Expand All @@ -79,7 +83,9 @@ PYTEST_XDIST_AUTO_NUM_WORKERS=1 TEST_LIBRARY=nodejs ./run.sh PARAMETRIC tests/pa

Until the helpers are released, use a master build as described in the [custom Node.js binary instructions](../../docs/execute/binaries.md#nodejs-library). The Node manifest currently targets master's `7.0.0-pre` development version; update that gate to the actual release version once published.

The protobuf fixture `tests/parametric/test_ffe/rules-wire.json` comes from `openfeature-js-client/packages/browser/test/data/rules-v1-wire.json`. The test checks serialization without evaluating flags or depending on a browser package.
The protobuf fixture `tests/parametric/test_ffe/rules-wire.json` comes from `openfeature-js-client/packages/browser/test/data/rules-v1-wire.json`. Fetch-only tests check serialization without evaluation; the fetch-then-precompute case also resolves this fixture for two contexts. Neither path depends on a browser package.

`precompute-rules.json` is the readable protobuf JSON source for `precompute-rules-wire.json`. It contains a US-targeted boolean, a false fallback with reason `DEFAULT`, a JSON-null assignment, an unassigned flag, and an unsupported-feature flag. The wire is encoded with `@bufbuild/protobuf`'s `fromJson`/`toBinary` and the `FlagsConfigurationSchema` from `flagging-core` at PR #448 commit `b2a42f26ce9ece08e5d317563b4246163d5d0acf`; it carries a deliberately distinct source ETag to check that precomputation does not forward it.

```bash
./run.sh FEATURE_FLAGGING_AND_EXPERIMENTATION --library <language>
Expand Down
7 changes: 7 additions & 0 deletions tests/parametric/test_ffe/precompute-rules-wire.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": 1,
"rules": {
"etag": "private-source-etag",
"response": "CgYIgPLWygYSBHRlc3QabwoIY2hlY2tvdXQSYxAEGgIoARoECAEoACJBCg11cy1hbGxvY2F0aW9uEAAiLBgqIAEqJgoKZXhwZXJpbWVudBIIY2hlY2tvdXQqBEhPT0sqCEVYUE9TVVJFKAEiEgoIZmFsbGJhY2siBhABGCsgBBorCgt1bnN1cHBvcnRlZBIcCOcHEAQaAigBIhEKC3Vuc3VwcG9ydGVkIgIgAxokCghudWxsYWJsZRIYEAUaBAgEMAAiDgoIbnVsbGFibGUiAiADGhQKCnVuYXNzaWduZWQSBhAEGgIoASIGEgQKAggDKgdlbmFibGVkKghkaXNhYmxlZCoCVVMqB2NvdW50cnkqCW51bGwtanNvbkIEbnVsbEoFKgMSAQJQAQ=="
}
}
44 changes: 44 additions & 0 deletions tests/parametric/test_ffe/precompute-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"createdAt": "2026-01-01T00:00:00Z",
"environmentName": "test",
"observeFullEvaluationData": true,
"strings": ["enabled", "disabled", "US", "country", "null-json"],
"attributes": [{"attributePath": {"segments": [{"objectKeyStringIndex": 3}]}}],
"conditions": [{"stringMembership": {"stringIndexes": [2]}}],
"jsonStrings": ["null"],
"flags": {
"checkout": {
"variationType": "VARIATION_TYPE_BOOLEAN",
"variations": [
{"keyStringIndex": 0, "booleanValue": true},
{"keyStringIndex": 1, "booleanValue": false}
],
"allocations": [
{
"key": "us-allocation",
"targetingConditionIndex": 0,
"logExposureEvent": true,
"splits": [{
"variationIndex": 0,
"reason": "REASON_TARGETING_MATCH",
"serialId": 42,
"features": [{"key": "experiment", "stringValue": "checkout", "destinations": ["HOOK", "EXPOSURE"]}]
}]
},
{"key": "fallback", "splits": [{"variationIndex": 1, "reason": "REASON_DEFAULT", "serialId": 43}]}
]
},
"unsupported": {
"minimumFeatureLevel": 999,
"variationType": "VARIATION_TYPE_BOOLEAN",
"variations": [{"booleanValue": true}],
"allocations": [{"key": "unsupported", "splits": [{"reason": "REASON_STATIC"}]}]
},
"nullable": {
"variationType": "VARIATION_TYPE_JSON",
"variations": [{"keyStringIndex": 4, "jsonStringIndex": 0}],
"allocations": [{"key": "nullable", "splits": [{"reason": "REASON_STATIC"}]}]
},
"unassigned": {"variationType": "VARIATION_TYPE_BOOLEAN", "variations": [{"booleanValue": true}]}
}
}
Loading
Loading