fix(openfeature): compute correct reason from allocation structure#224
Draft
leoromanovsky wants to merge 2 commits intomainfrom
Draft
fix(openfeature): compute correct reason from allocation structure#224leoromanovsky wants to merge 2 commits intomainfrom
leoromanovsky wants to merge 2 commits intomainfrom
Conversation
…oding TARGETING_MATCH - Three-way reason: rules?.length -> TARGETING_MATCH, shards.length -> SPLIT, else -> STATIC - Fix test-flag-that-does-not-exist fixture: reason should be ERROR (FLAG_NOT_FOUND), not DEFAULT
…ssertions - Remove optional marker from reason field in TestCaseResult interface - Remove conditional guard around reason assertion in flags-v1.spec.ts - Add reason field to all test fixture JSON files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The evaluator hardcodes
TARGETING_MATCHas the reason for all successful flag evaluations. The correct reason depends on the allocation structure:This aligns with the Go reference implementation in
dd-trace-goand the OpenFeature spec.Changes
evaluateForSubject.ts: Replace hardcodedTARGETING_MATCHwith inline three-way reason computation based onallocation.rulesandsplit.shardsTestCaseResult.types.ts: Makereasona required field (was optional) — every evaluation path returns a reasonflags-v1.spec.ts: Remove conditionalif (testCase.result.reason)guard — always assert reason unconditionallyDecisions
allocation.rules?.lengthis checked directly, not the result ofcontainsMatchingRule(which returnstruefor empty rules)startAt/endAtare NOT reason signals — they are time-window pre-filters onlytest-flag-that-does-not-exist.jsonreason changed fromDEFAULTtoERRORto match the provider's actualFLAG_NOT_FOUNDbehavior