open-feature / open-feature/flagd

feat!: implement numeric coercion contract

Open
#1,996 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1.0-prereq
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 bare int64(val) cast in ResolveIntValue with a lossless check (reject a non-zero fractional part and out-of-accessor-range values with TYPE_MISMATCH); 10.0 -> 10 and lossless widening to Float continue to work
  • contract applies uniformly to gRPC, OFREP, and in-process paths (no wire changes)
  • bump the flagd-schemas submodule 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-testbed submodule and adopt the new @numeric-coercion scenarios
  • 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.

Parent: https://github.com/open-feature/flagd/issues/1995

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.