test(openfeature): add null targeting key test coverage#5523
test(openfeature): add null targeting key test coverage#5523leoromanovsky wants to merge 4 commits intomasterfrom
Conversation
…ags_spec - Add 3 new test cases: static flag (returns value), sharded flag (returns TARGETING_KEY_MISSING), rule-match flag (returns value) - All 3 scenarios pass empty context hash to simulate nil targeting key - Confirms Ruby FFI correctly delegates null targeting key handling to libdatadog
|
Thank you for updating Change log entry section 👏 Visited at: 2026-03-27 21:29:50 UTC |
|
✨ Fix all issues with BitsAI or with Cursor
|
… for FFE team CODEOWNERS visibility
…lable Configuration.new(json) is defined by the C extension as a singleton method. Without the extension, Ruby's default Class#new calls initialize with 0 args, causing ArgumentError.
BenchmarksBenchmark execution time: 2026-03-31 03:43:09 Comparing candidate commit 460509d in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 0 unstable metrics.
|
| # Tests for OpenFeature spec OF.2: optional targeting key | ||
| # See: https://openfeature.dev/specification/sections/evaluation-context#requirement-311 | ||
| # | ||
| # When targeting key is missing (nil), SDKs must still attempt evaluation: | ||
| # - Static flags (no shards): return value normally | ||
| # - Sharded flags: return TARGETING_KEY_MISSING error | ||
| # - Rule-match flags (no shards): return value if rule matches on non-id attribute | ||
|
|
||
| RSpec.describe 'OpenFeature OF.2: Optional Targeting Key' do |
There was a problem hiding this comment.
minor: OF.2 is our internal SDK spec identifier, not openfeature
What does this PR do?
Adds test coverage for OpenFeature spec OF.2 (optional targeting key) to prove libdatadog handles nil targeting key correctly via the Ruby FFI layer.
Motivation:
The OpenFeature spec (Requirement 3.1.1, OF.2) defines targeting key as optional. The correct behavior (matching libdatadog's reference implementation) is:
""empty string"", returns valueid="", returns valuenull/missingTARGETING_KEY_MISSINGerror, returns defaultidfallback), returns value or falls throughRuby's evaluator delegates to libdatadog which already handles this correctly — the C extension passes
NULLwhentargeting_keyis absent from the context hash. This PR adds explicit test coverage proving the behavior.Change log entry
No customer-visible change. Test-only — adds coverage for optional targeting key behavior that already works correctly.
Additional Notes:
spec/datadog/open_feature/so@DataDog/feature-flagging-and-experimentation-sdkis auto-requested via CODEOWNERSConfiguration#get_assignmentdirectly to exercise the Rust FFI layer without mocksQuestion for reviewers: The existing
evaluation_engine_spec.rbmocksNativeEvaluator, so there's no integration spec testing the full OpenFeature provider → native evaluator → libdatadog path with real flag configs. Should we add one?How to test the change?
bundle exec rspec spec/datadog/open_feature/null_targeting_key_spec.rb3 scenarios:
STATICreasonTARGETING_KEY_MISSINGerrorTARGETING_MATCHreasonNext Steps
test-case-null-targeting-key.jsontoffe-system-test-datashared fixtures (separate fixture centralization project)