fix: Return empty prerequisites for a flag that fails to evaluate in all_flags_state - #483
Open
jsonbailey wants to merge 2 commits into
Open
fix: Return empty prerequisites for a flag that fails to evaluate in all_flags_state#483jsonbailey wants to merge 2 commits into
jsonbailey wants to merge 2 commits into
Conversation
…rror all_flags_state read result.prerequisites unconditionally even when a per-flag evaluation raised. The except branch set only detail, leaving result unbound (or holding a previous flag's value), so the first flag raising caused an UnboundLocalError that aborted the whole payload, and a later flag raising made that flag inherit the previous flag's prerequisites. Evaluator.evaluate() only catches its own EvaluationException, so any other exception from malformed flag data reaches this path. Bind prerequisites in both eval branches (success -> result.prerequisites, error -> []) so an error degrades only that flag. Mirrors the same fix in the new async client.
jsonbailey
marked this pull request as ready for review
August 6, 2026 22:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
all_flags_statereadresult.prerequisitesunconditionally even when a per-flag evaluation raised. Theexceptbranch set onlydetail, leavingresultunbound (or holding a previous flag's value), so:UnboundLocalErrorthat aborts the entire state payload;prerequisites.Evaluator.evaluate()only catches its ownEvaluationException; any other exception from malformed flag data propagates and reaches this path, so theexceptis genuinely reachable (rare, but real).Fix
Bind
prerequisitesin both eval branches (success →result.prerequisites, error →[]) so an evaluation error degrades only that flag. Adds a regression test (bad-first/good/bad-last) asserting noUnboundLocalErrorand that a failed flag does not inherit a neighbor's prerequisites.This mirrors the same fix in the new async client (
AsyncLDClient.all_flags_state).Draft — surfaced during the async SDK review; no Jira ticket.
Note
Low Risk
Small, localized change to error handling in
all_flags_statewith a targeted regression test; no auth or data-path changes.Overview
Fixes per-flag evaluation failures in
all_flags_stateso they no longer break the whole payload or leak another flag’s prerequisite metadata.LDClient.all_flags_statenow setsprerequisitesin both the success path (result.prerequisites) and the error path ([]), instead of always readingresult.prerequisitesafter the try/except. That avoidsUnboundLocalErrorwhen the first flag raises and stops a later failed flag from inheriting a neighbor’s prerequisites.Adds a regression test with
bad-first/good/bad-lastflag ordering to assert the call completes and failed flags omit prerequisites while a successful flag keeps its own.Reviewed by Cursor Bugbot for commit 4f10055. Bugbot is set up for automated code reviews on this repo. Configure here.