fix(ffe): validate regexes and canonical error codes - #9053
Conversation
There was a problem hiding this comment.
Pull request overview
Validates feature-flag regexes during parsing, preserves canonical ASCII alphanumeric semantics, and verifies canonical evaluator error codes.
Changes:
- Rejects invalid regex flags during configuration parsing.
- Translates POSIX
[:alnum:]to ASCII ranges. - Asserts fixture error codes against evaluator errors and metadata.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tracer/src/Datadog.Trace/FeatureFlags/Rcm/Model/ConditionConfiguration.cs |
Caches validated regexes and applies ASCII alphanumeric semantics. |
tracer/src/Datadog.Trace/FeatureFlags/Rcm/Model/FlagCollectionJsonConverter.cs |
Validates regex operands while parsing flags. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/FeatureFlagsEvaluatorTests.cs |
Adds invalid-regex and POSIX alphanumeric regressions. |
tracer/test/Datadog.Trace.Tests/FeatureFlags/FeatureFlagsEvaluatorTests.Bundle.cs |
Binds and verifies canonical error codes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
BenchmarksBenchmark execution time: 2026-08-14 06:15:41 Comparing candidate commit eeb6ceb in PR branch Found 0 performance improvements and 1 performance regressions! Performance is the same for 71 metrics, 0 unstable metrics, 65 known flaky benchmarks, 61 flaky benchmarks without significant changes.
|
Execution-Time Benchmarks Report ⏱️Execution-time results for samples comparing This PR (9053) and master. ✅ No regressions detected |
Summary of changes
Changes
MATCHESandNOT_MATCHESregex operands while parsing each flag, so an invalid regex invalidates that flag even when evaluation context would not reach the condition.[:alnum:]class.result.errorCodeagainst both the evaluator error and OpenFeature metadata.Reason for change
Motivation
The canonical fixtures exposed two conformance bugs left after #8616:
[:alnum:]was translated to Unicode letters and numbers, allowing values that the canonical evaluator rejects.The fixture runner also silently ignored
errorCode, so it could not catch regressions inPARSE_ERRORandFLAG_NOT_FOUNDbehavior.Implementation details
Decisions
Regexes are compiled and cached during flag parsing. A compile error causes only that flag to be recorded as invalid, so evaluating it returns
PARSE_ERROR; other flags in the same UFC remain available. Runtime match failures retain the existing no-match behavior.The POSIX class is translated to
0-9A-Za-zto match the portable fixture semantics.Test coverage
[:alnum:]coverage.errorCodeassertions.FeatureFlagsEvaluatorTests: 328 passed onnet9.0.FeatureFlagsEvaluatorTests: 328 passed onnetcoreapp3.1.Other details
Follow-up to #8616.