Repository navigation
fix!: Keep a multi-context kind whose targetingKey is not a string - #77
Merged
Merged
Conversation
Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
keelerm84
approved these changes
Nov 6, 2026
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.
Requirements
Related issues
OpenFeature provider spec (
OFP) Requirements 2.2.1 and 2.3.x inlaunchdarkly/sdk-specs.Describe the solution you've provided
In a multi-context, if an individual context had a
targetingKeythat was not a string, the converter silently dropped that whole kind with no log. For example,{'kind': 'multi', 'user': {'targetingKey': False, 'key': 'user-key'}, 'org': {...}}produced only theorgcontext.OFP 2.2.1 requires each top-level attribute to become a single context. Section 2.3 applies the key rules within each individual context, using its
targetingKeyin place of the OpenFeature targeting key. Under those rules, a non-stringtargetingKeyis not usable, so the provider falls back to a stringkey. If there is no key, the provider produces an invalid context and logs an error (2.3.5), rather than dropping the kind.The converter now treats a non-string nested
targetingKeyas absent and logs a warning, matching how a non-stringkeyis handled (2.3.4.1), then applies the normal key rules.test_create_multi_context_with_invalid_targeting_keyasserted the old dropping behavior, so it is updated. A new test covers the case with no fallback key.Describe alternatives you've considered
Keeping the drop and only adding a log. That would still lose targeting for a kind that has a valid
key, which the spec does not allow.Additional context
This changes behavior only for the malformed input above. Found during the weekly OpenFeature provider audit.
Link to Devin session: https://app.devin.ai/sessions/f7bc946afe8c41a28cf7f3f497fc8b9d
Open in Devin Desktop: https://app.devin.ai/desktop/session/f7bc946afe8c41a28cf7f3f497fc8b9d?variant=devin
SDK-3496
Note
Overview
Fixes multi-context conversion when an individual kind has a non-string
targetingKey. Previously that kind was silently omitted from the built context; it now logs a warning, treatstargetingKeyas unset (same pattern as a badkey), and continues with normal key resolution via the stringkeywhen present.Tests now expect a full multi-context (e.g.
userkept withkey'user-key') plus the warning, and add coverage where invalidtargetingKeyand no stringkeymake the overall context invalid instead of dropping only that kind.Reviewed by Cursor Bugbot for commit 4be37ad. Bugbot is set up for automated code reviews on this repo. Configure here.