Repository navigation
feat(api): name the invalid field in invalid_params on body decode failures - #436
Conversation
…ilures Refs #352 Change-Id: I135270d4134af7b76cca69e2626a5582b7ed2754 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (1)ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🛡️ Codex Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: 270c699aeb
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 270c699aeb
ℹ️ 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".
…in 400 Change-Id: I4726eb96d99e542e7732929e86e448e5e52b64f6 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
A
400for a request body that fails to decode now names the invalid field ininvalid_params, as in upstream'sValidationProblemDetails. This is PR 4 of the plan in #352 (issuecomment-6143529650).{"error":"invalid JSON body: json: cannot unmarshal number into Go struct field patchRepoRequest.default_branch of type string", ..., "invalid_params":[{"name":"default_branch","reason":"must be a string"}]}That item is upstream's own example for
PATCH /repos.Which failures name a field
namereason*json.UnmarshalTypeErrorwith a field path)default_branch,paths.0(an array element), orbase_repo.auth.token(members decoded on their own, such asbase_repoandupstream, are prefixed)must be a string,a boolean,an integer,a number,an object,an arraystrictJSON(strict note writes, the strictupstream/pullform): unknown memberauthor.xis not a known fieldstrictJSON: duplicate memberappears more than oncestrictJSON:nullmembermust not be nullstrictJSON: nested member that is not an objectmust be a JSON objectThese leave
invalid_paramsout, as upstream does when it cannot name a field: an unreadable or empty body, a JSON syntax error, trailing data, a body that is not an object, an empty member name ({"":1}), and encoding/json'sDisallowUnknownFieldserror (it carries no path).What stays the same
erroranddetailtext, status codes,code(bad_request), and theapplication/jsoncontent type.strictJSON's messages are unchanged (TestInvalidParamsForpins them).How
errorEnvelopegainsinvalid_params(omitempty).writeProblemParamsasserts that only a 400 carries it and that each item has anameand areason.writeInvalid(w, msg, cause)is the one writer for these 400s.invalidParamsFor(cause)derives the items from a*fieldErroror a*json.UnmarshalTypeError."invalid JSON body: "sites in the plain-envelope decoders callwriteInvalid.checkStrictObjectreturns*fieldErrorvalues whoseError()is the old message.Tests
TestProblemMembersMatchUpstreampins the member set to the spec'sProblemDetailsproperties plusinvalid_params, theInvalidParamproperties (name,reason), and upstream'sdefault_branch/must be a stringexample.assertProblemFields(run on every full-server plain-error assertion,pgandsqlitelanes) now fails on any member outside that set, and oninvalid_paramsthat is not a non-empty list on a 400.TestInvalidParamsFor: each decode-failure class, named or not.TestInvalidParamsOnBodyFailures(full server, both lanes): PATCH, alias PATCH, create, create-branch, nestedbase_repoandupstreammembers, and the strict notes append, plus negative controls (syntax error, wrong top-level type, unknownupstreammember, empty member name).Dogfood
The same requests ran on a real local-mode server (SQLite + files) built from
origin/main(5cadc73) and from this branch (270c699), then through the stable Go and TS SDKs (1.17.1). The only difference isinvalid_paramson the five nameable failures. SDK messages are identical, including the TS client's message for a create with a non-string default branch. The clips are real-time asciinema replays rendered with agg.pr4-ab.mp4
Docs:
docs/reference/http-api.md(Errors) and the RFC 9457 row ofdocs/explanation/wire-compatibility.md.Refs #352
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high