-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Summary
The flagd in-process provider does not implement $evaluators/$ref resolution. Flag configurations that use shared targeting rule fragments via $evaluators will silently fail — the raw {"$ref": "evaluatorName"} objects are left in the targeting rules and passed to the JSONLogic engine, where they cause evaluation errors.
All other SDKs with in-process evaluation (Go, Java, JS/TS, .NET, Python) implement this feature.
Expected Behavior
Given a flag configuration like:
{
"$evaluators": {
"emailSuffix": { "ends_with": [{ "var": "email" }, "@example.com"] }
},
"flags": {
"my-flag": {
"targeting": { "if": [{ "$ref": "emailSuffix" }, "variant-a", "variant-b"] }
}
}
}The $ref should be replaced with the corresponding evaluator body at parse time, producing:
{ "if": [{ "ends_with": [{ "var": "email" }, "@example.com"] }, "variant-a", "variant-b"] }Current Behavior
flag_parser.rs deserializes the flag configuration via serde_json::from_value with no evaluator transposition. The $evaluators block is ignored and $ref objects remain in targeting rules.
Implementation Notes
The approach used by all other SDKs is regex-based string replacement on the serialized JSON at parse time:
- Extract the
$evaluatorsmap from the configuration - For each evaluator, build a regex matching
"$ref": "<name>"(with the enclosing{}) - Replace matches with the serialized evaluator body (stripping outer braces)
- Deserialize the result
This should be added to crates/flagd/src/resolver/in_process/model/flag_parser.rs.
Related
- [BUG] $evaluators/$ref resolution: no parse-time validation, non-deterministic ordering, and missing Rust support flagd#1875 — Cross-SDK
$evaluators/$refresolution inconsistencies