-
Notifications
You must be signed in to change notification settings - Fork 42
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
Conversation
6b906b1
to
ec3d4c7
Compare
ec3d4c7
to
c0e6d0f
Compare
@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 |
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 failed before the fix.
})); | ||
|
||
// assert the correct overrides in after hook |
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 failed before the fix.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -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); |
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.
The instance of the evaluation context now changes here, but that's not something we guarantee.
74d2189
to
9a004bc
Compare
Signed-off-by: Todd Baert <[email protected]>
9a004bc
to
9dde9bb
Compare
Signed-off-by: Todd Baert <[email protected]>
|
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 <[email protected]>
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> Add support for the hook-data concept for hooks. Hook-data allows for per-evaluation data to be propagated between hooks. This is especially useful for analytics purposes where you may want to measure things that happen between stages, or you want to do something like create a span in one stage and close it in another. This concept is similar to the `series data` concept for LaunchDarkly hooks. https://github.com/launchdarkly/open-sdk-specs/tree/main/specs/HOOK-hooks#evaluationseriesdata Unlike `series data` the data in this approach is mutable. This is because the `before` stage already has a return value. We could workaround this by specifying a return structure, but it maybe seems more complex. The data is only passed to a specific hook instance, so mutability is not of great concern. Some functional languages may still need to use an immutable with return values approach. I can create an OFEP if we think this merits discussion prior to proposal. ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> Related discussion in a PR comment. open-feature/java-sdk#1049 (comment) --------- Signed-off-by: Ryan Lamb <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Lukas Reining <[email protected]> Co-authored-by: Todd Baert <[email protected]>
Fixes an issue where the fully merged and updated context was used in the evaluation, but not in all hooks.
Fixes: #1047