发布

  • [OPIK-6425] [FE] harden finiteOrNull: clamp negatives + coerce numeric strings

    frostbyte_neo 发布于 2026-06-25 20:48:09 +00:00

    Review follow-up. finiteOrNull is the single coercion point for explain metric
    payloads, so it must only emit a backend-valid number | null (backend models
    are float | None with ge=0):

    • negatives now → null. lodash isFinite is true for negatives, so a corrupt
      negative duration/cost (e.g. clock-skew) used to pass through and 422 against
      the backend's ge=0 — the same broken Explain button the fix removed.
    • numeric strings now coerced. A non-conforming API value ("5") collapsed to
      null ("not recorded") for a row that has a real value; coercing preserves the
      pre-fix behaviour where the backend parsed it.

    Direct unit test added pinning the helper's contract (0/positive pass, negatives
    / NaN / Infinity / absent → null, numeric strings coerced).

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件