Skip to content

fix: handle integer flag values serialized as floats#105

Merged
nicklasl merged 2 commits intomainfrom
nicklasl/fix-integer-float-coercion
Mar 9, 2026
Merged

fix: handle integer flag values serialized as floats#105
nicklasl merged 2 commits intomainfrom
nicklasl/fix-integer-float-coercion

Conversation

@nicklasl
Copy link
Member

@nicklasl nicklasl commented Mar 9, 2026

Summary

  • JSON doesn't distinguish between int and float, so backends may serialize integer values as 400.0. Updated primitive_matches to accept whole-number floats when expecting int, and accept int values when expecting float.
  • Added float-to-int conversion in _select so resolved values are returned as proper Python int.
  • Added integration tests covering: sync/async float-to-int coercion, negative values, zero, non-whole float rejection, and float-from-int resolution. Also added provider-layer coverage.

Test plan

  • Existing 61 tests still pass
  • 7 new tests in test_confidence.py pass (sync, async, edge cases, negative test)
  • 1 new test in test_provider.py passes (OpenFeature provider layer)
  • CI passes

🤖 Generated with Claude Code

nicklasl and others added 2 commits March 9, 2026 08:47
JSON doesn't distinguish between int and float numbers, so backends
may serialize integer values as 400.0. The SDK now coerces whole-number
floats to int when resolving integer flags, and accepts int values
when resolving float flags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nicklasl nicklasl marked this pull request as ready for review March 9, 2026 08:06
@nicklasl nicklasl merged commit 8b73f3f into main Mar 9, 2026
7 checks passed
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.

2 participants