Repository navigation
Description
Tracking issue for implementing the numeric coercion ADR across flagd, flagd-schemas, flagd-testbed, and all flagd providers.
Contract summary
Per docs/architecture-decisions/numeric-coercion.md (merged in #1979):
- Numeric variants are returned through a numeric accessor only when the conversion is lossless; otherwise
TYPE_MISMATCH. - Numeric flag values are constrained to the IEEE-754 safe-integer range,
[-(2^53 - 1), 2^53 - 1], in the flag-definition schema. This is an ordinary schema validation, surfaced like any other schema validation (today flagd logs schema violations as warnings; that behavior is unchanged). Hard-failing a load on schema violations is intentionally out of scope for this work and is tracked separately as its own feature. - The lossless-coercion contract applies identically across gRPC, OFREP, and in-process evaluation.
- Implementations log a warning after parsing a configuration, for each numeric variant outside the safe-integer range (see flagd#2100). This doesn't depend on schema validation, so every in-process evaluator should implement it.
- Int bounds are relative to the accessor in use. Accessor widths differ by language; the shared testbed treats
Long(int64) as the canonical wide numeric accessor and only encodes language-agnostic assertions, with int32-specific cases behind@int32-bounded.
Per-language accessor widths
| Language | Integer accessor | Long accessor | Notes |
|---|---|---|---|
| Go (flagd-core) | int64 (ResolveIntValue) |
same (int64 is canonical) | no separate Long; Integer is the canonical Long, so Go excludes @int32-bounded |
| Java | int32 (getInteger) |
int64 (getLong, java-sdk#1985) |
Long safe-delegates to int; canonical wide accessor |
| .NET | int32 | int64 (Int64) |
|
| Python | arbitrary-precision int | n/a | effectively wide |
| JS / Web | double | double | no int64; exact up to 2^53 - 1 (the cap) |
Float accessors cap at the safe-integer range.
No wire format changes. AnyFlag.double_value in ResolveAll remains as-is; the ADR intentionally treats the parsed int/float JSON type as non-authoritative, which keeps bulk eval faithful under the same rule.
Breaking change scope
- Callers relying on silent truncation (Go, Java in-process):
3.14viagetIntegerDetailsreturnsTYPE_MISMATCHinstead of3. - Some SDKs flip the other way:
10.0viagetIntegerDetailsreturns10(previouslyTYPE_MISMATCHin Python and .NET). - Config authors: flag definitions with numeric values outside
[-(2^53 - 1), 2^53 - 1]fail schema validation (a load-time warning today, consistent with every other schema validation). They are not hard-rejected at load by this work.
flagd is pre-1.0, so the coercion behavior change ships as a feat!: minor bump with breaking changes called out in release notes.
Testbed rollout
There is no existing numeric-coercion suite to preserve. This work adds a new, opt-in @numeric-coercion tagged suite (following the opt-in @fractional-v1/@fractional-v2 precedent) so providers adopt it as they migrate. Coverage is added to both the provider gherkin/ suite and the self-contained evaluator/ suite. Width-specific expectations sit behind @int32-bounded; wide and boundary values use the canonical Long accessor.
Rollout order
flagd-schemas: add the safe-integer range to numeric variant values (schema validation)flagd-testbed: add ADR-conformant scenarios under@numeric-coercion(both suites), release new tagflagd+ flagd-core (Go): implement the lossless-coercion contract, bump testbed submodule- Providers (in parallel once the testbed tag lands): bump testbed submodule, implement the lossless-coercion contract in each in-process resolver; for JS
flagd-web(the onlyResolveAllconsumer), verify bulk results match individualResolve* - Coordinated provider releases
Child issues
- flagd-schemas: feat!: cap numeric flag variants at IEEE-754 safe integer range flagd-schemas#219
- flagd-testbed: feat: add ADR-conformant numeric coercion scenarios under @numeric-coercion flagd-testbed#379
- flagd (core + Go flagd-core): feat!: implement numeric coercion contract #1996
- go-sdk-contrib: feat!: adopt numeric coercion contract go-sdk-contrib#923
- java-sdk-contrib: feat!: adopt numeric coercion contract java-sdk-contrib#1822
- js-sdk-contrib: feat!: adopt numeric coercion contract js-sdk-contrib#1578
- python-sdk-contrib: feat!: adopt numeric coercion contract python-sdk-contrib#402
- dotnet-sdk-contrib: feat!: adopt numeric coercion contract dotnet-sdk-contrib#709
- php-sdk-contrib: feat!: adopt numeric coercion contract php-sdk-contrib#169
- rust-sdk-contrib: feat!: adopt numeric coercion contract rust-sdk-contrib#151
Related
- ADR: https://github.com/open-feature/flagd/blob/main/docs/architecture-decisions/numeric-coercion.md
- ADR PR: docs: add numeric coercion proposal #1979
- Original issue: [FEATURE] Define numeric coercion behavior across flagd implementations #1978
Activity
Rabbhit commentedon Aug 24, 2026
Hi @toddbaert!
I'd like to help move this forward. Would like to pick up in sequence:
@numeric-coercion-v2Gherkin scenarios + fixtures (gherkin/ and evaluator/ suites), andcore/pkg/evaluator/json.go, validated against the new testbed scenariosOne thing I noticed looking into the provider repos,
php-sdk-contribhas no in-process resolver at all (only an RPC/HTTP client to a real flagd instance), so "implement in in-process resolver + apply to ResolveAll" scope doesn't map onto that repo's current architecture and it'll mostly inherit the fix once core ships. Is this something to take into consideration? Does that change how we want that sub-issue scoped?