Skip to content

Commit 6cee589

Browse files
nicklaslclaude
andauthored
fix(resolver): skip targeting_key validation when rule has blank selector (#383)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0618082 commit 6cee589

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

confidence-resolver/src/lib.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,22 @@ impl<'a, H: Host> AccountResolver<'a, H> {
10591059
continue;
10601060
}
10611061
}
1062-
Err(_) => return Ok(resolved_value.error(ResolveReason::TargetingKeyError)),
1062+
Err(_) => {
1063+
// Mirror Java: only skip targeting_key validation when the
1064+
// rule has a blank selector AND is a 100% rollout — i.e. no
1065+
// code path downstream needs the key. Non-blank selectors
1066+
// always validate; partial rollouts need the key to bucket.
1067+
let is_full_rollout = rule
1068+
.assignment_spec
1069+
.as_ref()
1070+
.map(has_only_one_full_variant)
1071+
.unwrap_or(false);
1072+
if rule.targeting_key_selector.is_empty() && is_full_rollout {
1073+
None
1074+
} else {
1075+
return Ok(resolved_value.error(ResolveReason::TargetingKeyError));
1076+
}
1077+
}
10631078
};
10641079

10651080
let Some(spec) = &rule.assignment_spec else {

confidence-resolver/test-payloads/resolver-spec/tests.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3575,18 +3575,6 @@
35753575
}
35763576
],
35773577
"expectError": null
3578-
},
3579-
"rust": {
3580-
"resolvedFlags": [
3581-
{
3582-
"flag": "flags/catch-all-100pct-flag",
3583-
"reason": "RESOLVE_REASON_TARGETING_KEY_ERROR",
3584-
"variant": "",
3585-
"value": null,
3586-
"shouldApply": false
3587-
}
3588-
],
3589-
"expectError": null
35903578
}
35913579
}
35923580
},
Binary file not shown.

0 commit comments

Comments
 (0)