{{ message }}
Repository navigation
fix: reject boolean values for integer flags - #621
Merged
gruebel merged 4 commits intoAug 30, 2026
Merged
Conversation
Exclude bool from integer flag type checks while preserving other integer subclasses. Return the caller default when the async client detects a type mismatch, matching the sync path. Cover sync and async value/details getters, exact fallback types, hook behavior, and valid flag values with regression tests for open-feature#619. Signed-off-by: Hexecu <vaingloryhex@gmail.com>
Hexecu
force-pushed
the
fix/reject-boolean-integer-flags
branch
from
August 30, 2026 06:08
e530620 to
71fe148
Compare
Document the boolean/integer distinction, async type-mismatch fallback, and the regression cases. Keep the evaluation logic and test assertions unchanged. Signed-off-by: Hexecu <vaingloryhex@gmail.com>
Hexecu
force-pushed
the
fix/reject-boolean-integer-flags
branch
from
August 30, 2026 06:40
10f26c1 to
1e2e89d
Compare
gruebel
reviewed
Aug 30, 2026
gruebel
left a comment
Member
There was a problem hiding this comment.
thanks for the PR, i added a few comments, nothing critical
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #621 +/- ##
==========================================
+ Coverage 98.39% 98.43% +0.03%
==========================================
Files 45 45
Lines 2561 2621 +60
==========================================
+ Hits 2520 2580 +60
Misses 41 41
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
Signed-off-by: Hexecu <vaingloryhex@gmail.com>
Hexecu
force-pushed
the
fix/reject-boolean-integer-flags
branch
from
August 30, 2026 15:05
a153f93 to
4e16c60
Compare
This was referenced Sep 11, 2026
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.

This PR
I reproduced the behavior reported by @aepfli in #619: requesting a boolean flag through
get_integer_detailsreturns the boolean as a successful evaluation, instead of returning the integer default withTYPE_MISMATCH.The caller gets neither the expected type nor an indication that the flag is misconfigured for that request. The fallback is silently bypassed because Python considers
boola subclass ofint, soisinstance(True, int)passes the client's type check.Reproducing the problem
This example uses the built-in provider; no flag server or credentials are needed. Run it with
uv run --frozen python repro.pyafter saving it asrepro.pyin the checkout:On the base commit,
371aca1:With this patch, the same example returns the supplied default and reports the mismatch:
I also checked
Falsewith a default of0. The type matters here: a test that only checks equality would pass even before the fix, sinceTrue == 1andFalse == 0.Why there are two changes
The shared type check now excludes booleans when the requested type is INTEGER. I kept
isinstancefor everything else so this doesn't also reject valid integer subclasses or change how other flag types are handled.That change alone wasn't enough for the async API. While checking it, I found that the async type-mismatch branch still constructed its result with
resolution.value. It reported an error, but returned the rejected value anyway. The second change usesdefault_valuein that branch, matching the sync behavior.This also corrects the async fallback for other client-detected type mismatches, which is why the tests cover more than bool-to-int. It doesn't change provider implementations or introduce type coercion. Boolean flags and objects containing booleans continue to work as before.
Related Issues
Fixes #619. Thanks @aepfli for the reproduction and the conformance test that caught this.
How to test
The added tests exercise both value and details getters through the real
InMemoryProvider. They check the exact return type as well as the value, error details and hook behavior: a mismatch must run the error hook, skip the after hook, and give the finally hook the fallback value. There are also passing cases for valid flag values and an integer subclass, to check that the stricter bool handling doesn't affect them.To run just these tests:
uv run --frozen pytest tests/test_client.py -q \ -k 'client_returns_default_on_type_mismatch or client_preserves_matching_flag_types or typecheck_flag_value_accepts_integer_subclasses'I ran the same 39 cases against the unmodified base and this patch. Before the fix, 11 failed and 28 passed: the failures were the two sync bool-to-int cases and the nine async mismatch cases. After the fix, all 39 passed.
The full suite passed on Python 3.10 through 3.14, with 211 tests on each version. The repository's Gherkin suite also passed on each version: 21 scenarios / 84 steps, using its pinned spec and in-memory provider. Ruff, mypy, the remaining pre-commit hooks, and the wheel/sdist build passed locally as well.
Notes
For a check independent of the tests added here, I ran the in-memory self-test from python-sdk-contrib#409, at
d6de5dc, against both SDK versions. The case marked as a known failure for #619 becomesXPASS(strict)with this patch. Running that unchanged test file with--runxfail, so the assertions run normally, gives 24 passed and 5 skipped. The skips are unsupported provider capabilities; the strict marker will need updating when that suite adopts the fixed SDK.All results above are local macOS runs. I haven't tested against live flagd/OFREP servers, and these results don't replace hosted CI.