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: hooks not run in NOT_READY/FATAL #1392

Merged
merged 2 commits into from
Mar 27, 2025

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Mar 26, 2025

Fixes a bug where our "short circuit" logic was "short circuiting" too early, leading to various errors in hooks.

Fixes: #1370

@toddbaert toddbaert requested a review from a team as a code owner March 26, 2025 18:26
@toddbaert toddbaert force-pushed the fix/fatal-not-running-hooks-appropriately branch from cd7f5cc to 539e787 Compare March 26, 2025 18:41
@toddbaert toddbaert force-pushed the fix/fatal-not-running-hooks-appropriately branch from 539e787 to 72ce106 Compare March 26, 2025 18:43
Signed-off-by: Todd Baert <[email protected]>
Comment on lines -181 to -186
if (ProviderState.NOT_READY.equals(state)) {
throw new ProviderNotReadyError("provider not yet initialized");
}
if (ProviderState.FATAL.equals(state)) {
throw new FatalError("provider is in an irrecoverable error state");
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Throwing these before we ran the hooks and setup the afterHookContext was the cause of the issue. We just needed to move it later.

@@ -594,6 +594,25 @@ void erroneous_flagResolution_setsAppropriateFieldsInFlagEvaluationDetails() {
assertThat(evaluationDetails.getValue()).isTrue();
}

@Test
void shortCircuit_flagResolution_runsHooksWithAllFields() {
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 test fails without the fix.

Copy link

codecov bot commented Mar 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.25%. Comparing base (7536679) to head (c5fd560).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1392      +/-   ##
============================================
+ Coverage     92.90%   93.25%   +0.35%     
- Complexity      470      471       +1     
============================================
  Files            43       43              
  Lines          1127     1127              
  Branches         91       91              
============================================
+ Hits           1047     1051       +4     
+ Misses           53       48       -5     
- Partials         27       28       +1     
Flag Coverage Δ
unittests 93.25% <100.00%> (+0.35%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@toddbaert toddbaert merged commit 24ef9dd into main Mar 27, 2025
12 checks passed
@toddbaert toddbaert deleted the fix/fatal-not-running-hooks-appropriately branch March 27, 2025 13:22
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.

[BUG] NullPointerError encountered while running flagd in NoOpProvider mode
2 participants