-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve targetingKey handling in the context #805
fix: improve targetingKey handling in the context #805
Conversation
@@ -184,7 +183,7 @@ public class EvalContextTest { | |||
|
|||
ctx2.setTargetingKey(" "); | |||
ctxMerged = ctx1.merge(ctx2); | |||
assertEquals(key1, ctxMerged.getTargetingKey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only major change - we do not accept empty value or spaces for targeting key. Eaerlier this was handled in the merge stage where we filtered for null or empty values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
8b5eef6
to
b9f4469
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #805 +/- ##
============================================
+ Coverage 94.89% 95.39% +0.49%
- Complexity 365 368 +3
============================================
Files 34 34
Lines 862 847 -15
Branches 53 50 -3
============================================
- Hits 818 808 -10
+ Misses 23 21 -2
+ Partials 21 18 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@Kavindu-Dodan This seems like a good idea to me. We recently had a bug in flagd-java due to this. I think the risk is low but I'm interested in what others think. Do you think we should do the same thing in dotnet? cc @kinyoklion @austindrenski |
I like this idea. Prior to it being formalized into the API of the context itself I had been targeting the "targetingKey" based on a string constant. A snippet from the documentation for the LaunchDarkly dotnet provider.
By storing it in an attribute it would theoretically maintain compatibility with those assumptions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense and the change looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kavindu-Dodan would you mind creating a similar .NET issue if you agree?
Created a .Net issue - open-feature/dotnet-sdk#235 I will merge this as we have an agreement on the change :) |
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
b9f4469
to
1c18a9e
Compare
Quality Gate passedIssues Measures |
This PR
Fixes #801.
What's changed?
I have changed how we store the targetingKey internally (in both mutable and immutable contexts). Instead of storing in a field, we now store targetingKey as a property of the delegated Structure implemementation.
Why
Both mutable and immutable contexts use a Structure implementation instance and delegate operations onto this instance. For example,
asObjectMap
andasMap()
are exposed through this delegation. With this change, we keep the same delegation and expose targetingKey from the above-mentioned attribute exporters.Impact
There are no behaviour change other than for avoiding storing of empty string (
""
) for targetingKey.