Skip to content

PLAT-1314/fix: skip local validation for numbers float64 cannot hold exactly - #15

Merged
brtkwr merged 2 commits into
mainfrom
bkunwar/plat-1314-number-precision
Nov 3, 2026
Merged

brtkwr merged 2 commits into
mainfrom
bkunwar/plat-1314-number-precision

Conversation

@brtkwr

@brtkwr brtkwr commented Nov 3, 2026

Copy link
Copy Markdown
Member

Context

Follow-up to #13, from the Codex finding #13 (comment). Payload validation decoded numbers as float64, so 36.000000000000001 could pass an integer or maximum: 36 check, and numbers outside float64 range (e.g. 1e400) were reported as "not valid JSON".

Changes

  • Request bodies are decoded losslessly (json.Number).
  • If every number round-trips through float64 unchanged (0.1, 42, 9007199254740992), validation runs exactly as before.
  • If any number cannot (36.000000000000001, 9007199254740993, 1e400, 1e-400), the CLI prints warning: number at "/path" cannot be checked exactly; skipping local schema validation (the API will validate it) and sends the body unchanged. Same fail-open style as the unknown-property warning.

Scope / Non-goals

  • No exact numeric validation of our own: kin-openapi converts numbers to float64 internally, so those rare payloads get no local check and the API stays the authority.
  • The bytes sent to the API are unchanged in every case.

Validation

  • go test ./cmd/twoctl/cli/ -run TestPayload passed locally; new cases cover exact decimals still rejected for integer fields, lost fractions, integers beyond 2^53, overflow, underflow, nested paths and negative zero. Full suite left to CI.

Ticket

🤖 Generated with Claude Code

https://claude.ai/code/session_01QUnP8hJ3og3dxSHHcYij5n

…exactly

Payload validation decoded numbers as float64, so 36.000000000000001 could
pass an integer or maximum check and numbers outside float64 range were
reported as invalid JSON. Numbers are now decoded losslessly; when one cannot
be represented exactly, the CLI warns and sends the body unchanged for the
API to validate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUnP8hJ3og3dxSHHcYij5n
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T08:52:22.764544Z a92d094 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@brtkwr
brtkwr requested a review from Puvendhan November 3, 2026 08:50
Keeps validatePayload under the gocyclo threshold of 15.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUnP8hJ3og3dxSHHcYij5n
@brtkwr
brtkwr merged commit 96e3c44 into main Nov 3, 2026
@brtkwr
brtkwr deleted the bkunwar/plat-1314-number-precision branch November 3, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant