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: updated context not passed to all hooks #1049

Merged
merged 2 commits into from
Aug 20, 2024
Merged

fix: updated context not passed to all hooks #1049

merged 2 commits into from
Aug 20, 2024

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Aug 15, 2024

Fixes an issue where the fully merged and updated context was used in the evaluation, but not in all hooks.

Fixes: #1047

@toddbaert
Copy link
Member Author

@UtkarshSharma2612 feel free to add yourself as a reviewer if you want 🙏

// assert the connect overrides
c.getBooleanValue("key", false, invocationCtx, FlagEvaluationOptions.builder().hook(hook).build());

// assert the correct overrides in before hook
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed before the fix.

}));

// assert the correct overrides in after hook
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed before the fix.

Copy link

codecov bot commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.27%. Comparing base (7cac198) to head (88ecaf4).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1049      +/-   ##
============================================
+ Coverage     95.04%   95.27%   +0.22%     
- Complexity      392      393       +1     
============================================
  Files            38       38              
  Lines           888      888              
  Branches         54       54              
============================================
+ Hits            844      846       +2     
+ Misses           24       23       -1     
+ Partials         20       19       -1     
Flag Coverage Δ
unittests 95.27% <100.00%> (+0.22%) ⬆️

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.

@@ -503,7 +504,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
order.verify(hook2).before(captor.capture(), any());

HookContext hc = captor.getValue();
assertEquals(hc.getCtx(), ctx);
assertEquals(hc.getCtx().getTargetingKey(), targetingKey);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instance of the evaluation context now changes here, but that's not something we guarantee.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Copy link

sonarcloud bot commented Aug 20, 2024

@toddbaert toddbaert merged commit dbf967a into main Aug 20, 2024
10 checks passed
@toddbaert toddbaert deleted the fix/hook-ctx branch August 20, 2024 19:33
toddbaert added a commit to open-feature/js-sdk that referenced this pull request Aug 23, 2024
There's no bug here, but this adds some asserts for a tricky bug I
recently found in the Java SDK:
open-feature/java-sdk#1049

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
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.

Hooks are not passed merged context
4 participants