Skip to content

PLAT-1314/feat: validate JSON payloads before API requests - #13

Merged
brtkwr merged 10 commits into
mainfrom
bkunwar/plat-1314-payload-validation
Nov 3, 2026
Merged

brtkwr merged 10 commits into
mainfrom
bkunwar/plat-1314-payload-validation

Conversation

@brtkwr

@brtkwr brtkwr commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Changes

  • Validate JSON payloads against the embedded request schema before ordinary or paginated API requests, including dry runs.
  • Reject malformed JSON, empty required bodies, missing required fields, type and enum mismatches with usage exit code 2.
  • Warn on unknown structured properties without dropping them from the HTTP payload or blocking spec drift.
  • Validate a private payload projection against the original schema, preserving closed oneOf discrimination, composed array items, typed/open maps and shared schema contents.
  • Keep payload values out of validation diagnostics and warnings off stdout.
  • Add inline/file/stdin, nested schema, composition, immutability, dry-run and no-network regressions; document the behavior.

Validation

On exact head bb8c8ad5d4aa07f41ba2ccba9bc4da3d4ca29aa1, CI run 41433101885 passed both jobs:

  • build: go build ./..., embedded-spec drift check, all tests and coverage gate passed. Total coverage 82.0% (80% gate).
  • lint: formatting, vet, ineffassign, spelling, complexity and golint passed.
  • No tests run locally, as requested. All six changed files were re-read from the exact remote head.
  • Focused independent review found closed oneOf and composed-array warning edge cases; both now have regressions.

Scope

Refs PLAT-1314. Other checklist items and open PR scopes remain separate. Validation uses the existing kin-openapi OAS validator; this does not add a new JSON Schema engine or change embedded specs.

Integration status — 2 November 2026

Merged current main (8a3ba6e9fb8269f4d6056c7419895902641ee356) into this branch without force-pushing. The merge was automatic; existing validation behavior and upstream retry/context/keychain changes are preserved. GitHub now reports no merge conflicts.

No approval is recorded. Suggested review/merge sequence: this PR before interactive pagination (PR #14), then refresh #14 against the resulting main and rerun CI. A Git integration check found overlapping README/pagination edits between those PRs; neither has been merged by this repair.

✨ via Codex session

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-03T07:14:53.205410Z f054d90 New commits
ℹ️ 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.

@Puvendhan Puvendhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked payloads are validated against the embedded schema in both single and paginated paths without echoing values in errors; no open findings; CI green.


Generated by Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f054d90f12

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +25 to +26
var value any
if err := json.Unmarshal(raw, &value); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve JSON number precision during validation

When a payload contains a high-precision number, unmarshalling into any converts it to float64 before schema validation. This can change the value or even turn a non-integer into an integer—for example, 36.000000000000001 rounds to 36 and can pass an integer schema with maximum: 36; sufficiently large valid JSON numbers also fail decoding as though the JSON were malformed. Validate a lossless numeric representation so constraints are checked against the value that will actually be sent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #15: numbers are decoded losslessly, and any that float64 can't hold exactly skip local validation with a warning so the API decides.

The diagnostics test from #12 posted an arbitrary body to order create,
which payload validation now rejects before the request is sent. It now
uses a probe operation whose schema declares the fields it sends.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUnP8hJ3og3dxSHHcYij5n
@brtkwr
brtkwr merged commit 074e899 into main Nov 3, 2026
@brtkwr
brtkwr deleted the bkunwar/plat-1314-payload-validation branch November 3, 2026 08:46
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.

2 participants