fix: [openfeature] allow empty targeting key in exposure events#4361
Conversation
The exposure schema (exposure.json) requires subject.id to be a string but does not enforce a minimum length, meaning empty strings are valid. Previously, the exposure hook would skip logging exposures when the targeting key was empty. This prevented server-side flag evaluations (which often don't have a user context) from being tracked. This change removes that restriction, allowing exposures with empty targeting keys to be sent to the event platform.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-01-16 16:27:55 Comparing candidate commit 62210ff in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 158 metrics, 6 unstable metrics. |
Add comprehensive tests for the exposure hook's After method: - Test with non-empty targeting key (standard case) - Test with empty targeting key (server-side evaluations) - Test missing allocation key (should skip exposure) - Test doLog=false (should skip exposure) - Test nil metadata (should skip exposure) - Test empty targeting key with attributes (verifies attributes are preserved) - Test cancelled context (should return error and skip exposure)
Empty targeting key is valid, no need to conditionally exclude it.
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
Tests failed on this commit 77695fc:
What to do next?
|
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
|
Co-authored-by: leo.romanovsky <leo.romanovsky@datadoghq.com>
The OpenFeature Java SDK 1.20.1 fixed the empty targeting key issue (open-feature/java-sdk#1807), and dd-trace-go main also has the fix (DataDog/dd-trace-go#4361). Only Node.js (FFL-1730) still needs the skip.
Motivation
The exposure schema (exposure.json) requires subject.id to be a string but does not enforce a minimum length, meaning empty strings are valid.
Previously, the exposure hook would skip logging exposures when the targeting key was empty. This prevented server-side flag evaluations (which often don't have a user context) from being tracked.
SDK Specification | EXP.5
-->
What does this PR do?
This change removes that restriction, allowing exposures with empty targeting keys to be sent to the event platform.
system test relevant to this: DataDog/system-tests#6040
Reviewer's Checklist
./scripts/lint.shlocally.Unsure? Have a question? Request a review!