Skip to content

feat!: implement numeric coercion contract #1996

Open

Description

@toddbaert

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: #1995

Activity

  1. 280 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions