Skip to content
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: missing targeting key should return null #849

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

liran2000
Copy link
Member

@liran2000 liran2000 commented Mar 17, 2024

Problem:
getTargetingKey of missing targeting key causing NullPointerException.
Solution:
getTargetingKey of missing targeting key returns null.

failing java-sdk-contrib CI:

Error:  dev.openfeature.contrib.providers.flagd.resolver.process.targeting.OperatorTest.timestampPresent -- Time elapsed: 0.006 s <<< ERROR!
java.lang.NullPointerException
	at dev.openfeature.sdk.ImmutableContext.getTargetingKey(ImmutableContext.java:65)
	at dev.openfeature.contrib.providers.flagd.resolver.process.targeting.Operator.apply(Operator.java:52)

When adopting #805, saw an issue when checking missing targeting key when it is required, causing the check to not work properly:

if (ctx.getTargetingKey() == null) {
    throw new TargetingKeyMissingError("targeting key is required.");
}

Related test check can be updated after this fix.

@liran2000 liran2000 requested a review from a team as a code owner March 17, 2024 07:54
@liran2000 liran2000 changed the title missing targeting key should return null fix: missing targeting key should return null Mar 17, 2024
Copy link

codecov bot commented Mar 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (433f94a) to head (3c9c301).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #849      +/-   ##
============================================
+ Coverage     95.15%   95.52%   +0.36%     
- Complexity      367      371       +4     
============================================
  Files            34       34              
  Lines           847      849       +2     
  Branches         50       52       +2     
============================================
+ Hits            806      811       +5     
+ Misses           22       20       -2     
+ Partials         19       18       -1     
Flag Coverage Δ
unittests 95.52% <100.00%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kavindu-Dodan
Copy link
Contributor

@liran2000 thanks a lot for the NPE fix :)

Problem:
getTargetingKey of missing targeting key causing NullPointerException
Solution:
getTargetingKey of missing targeting key returns null

Signed-off-by: liran2000 <liran2000@gmail.com>
Signed-off-by: liran2000 <liran2000@gmail.com>
Copy link

sonarcloud bot commented Mar 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@toddbaert toddbaert merged commit 48a196c into open-feature:main Mar 22, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants