open-feature / open-feature/flagd
feat!: implement numeric coercion contract
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 997
- Forks
- 136
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 11
Description
Implements the numeric coercion ADR in flagd and flagd-core (Go).
- implement lossless numeric coercion in the evaluator (
core/pkg/evaluator/json.go): replace the bareint64(val)cast inResolveIntValuewith a lossless check (reject a non-zero fractional part and out-of-accessor-range values withTYPE_MISMATCH);10.0 -> 10and lossless widening toFloatcontinue to work - contract applies uniformly to gRPC, OFREP, and in-process paths (no wire changes)
- bump the
flagd-schemassubmodule to pick up the safe-integer range constraint. This remains an ordinary schema validation (surfaced as today, i.e. a warning); no new hard load-failure path is added here. Hard-failing on schema violations is a separate future feature. - bump the
flagd-testbedsubmodule and adopt the new@numeric-coercionscenarios - update ADR status:
draft->accepted; add the per-language accessor-width table
Accessor width: Go's ResolveIntValue is int64, i.e. Go's Integer accessor is the canonical Long. Go therefore excludes the @int32-bounded testbed scenarios; no separate Long accessor is required in Go core.
Breaking (lossless coercion changes existing truncation behavior, e.g. 3.14 via Integer now returns TYPE_MISMATCH); feat!:, minor bump, call out in release notes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/pkg/evaluator/json.go and the numeric coercion ADR, then inspect the gRPC, OFREP, and in-process paths for their shared behavior. Bump the flagd-schemas and flagd-testbed submodules, adopt the @numeric-coercion scenarios while excluding Go's @int32-bounded cases, and update the ADR status and accessor-width table. Done means lossless coercion passes the testbed contract and release notes cover the breaking change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 64/100