Skip to content

Report a rejected parameter as a validation failure - #4

Merged
terrylinooo merged 1 commit into
mainfrom
fix/validation-on-422
Aug 8, 2026
Merged

Report a rejected parameter as a validation failure#4
terrylinooo merged 1 commit into
mainfrom
fix/validation-on-422

Conversation

@terrylinooo

Copy link
Copy Markdown
Contributor

Recording the requests the API refuses turned up a shape nothing had covered,
and it was being classified wrongly.

A rejected parameter answers 422 with a message and a per-field errors bag:

{"message": "The given data was invalid.", "errors": {"urls.0.type": ["The selected urls.0.type is invalid."]}}

That shape has no msg key, so the dispatcher reads it as the single-URL
format — which had no 422 branch. It fell through to the catch-all and was
reported as a ServerException. The batch format has always mapped 422;
this one was simply missing it.

The cost was not only a wrong label. A caller catching ValidationException to
tell a user which field was wrong caught nothing, and the fields themselves
were never read by any branch. It also invites a retry of something that will
never succeed.

Why this took a second round of recording

Requests the API refuses create nothing and cost nothing, which makes them the
cheapest recordings to take — and they are the only way to reach the error
branches a successful run never touches. Two are added here: this one, and the
404 all three endpoints answer when a key cannot be resolved.

The second one closed a real gap. The Node SDK has a check that runs both SDKs
over these same recordings and compares them, and a deliberate mistake in the
batch 404 rule used to pass it untouched, because nothing recorded reached
that branch. It fails now.

Worth noting what that check could not do: both SDKs classified the 422
identically, because both were wrong in the same way. Comparing implementations
catches drift between them; only recording catches them drifting together from
the service.

The plan records both findings in §0.4.

🤖 Generated with Claude Code

Recording the requests the API refuses turned up a shape nothing had covered:
a rejected parameter answers 422 with a message and a per-field errors bag.
That shape has no msg key, so it is read as the single-URL format — which had
no 422 branch, so it fell through to the catch-all and was reported as a
server fault. The batch format has always mapped 422; this one was simply
missing it.

The cost was not just a wrong label. A caller catching a validation failure to
show a user which field was wrong caught nothing, and the fields themselves
were never read by any branch.

Refused requests create nothing and cost nothing, which makes them the
cheapest recordings to take and the ones that reach the error branches a
successful run never will. Two are added here: this, and the 404 all three
endpoints answer when a key cannot be resolved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@terrylinooo
terrylinooo merged commit 0ddd104 into main Aug 8, 2026
9 checks passed
@terrylinooo
terrylinooo deleted the fix/validation-on-422 branch August 8, 2026 03:20
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