Report a rejected parameter as a validation failure - #4
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recording the requests the API refuses turned up a shape nothing had covered,
and it was being classified wrongly.
A rejected parameter answers
422with 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
msgkey, so the dispatcher reads it as the single-URLformat — which had no
422branch. It fell through to the catch-all and wasreported as a
ServerException. The batch format has always mapped422;this one was simply missing it.
The cost was not only a wrong label. A caller catching
ValidationExceptiontotell 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
404all 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
404rule used to pass it untouched, because nothing recorded reachedthat branch. It fails now.
Worth noting what that check could not do: both SDKs classified the
422identically, 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