Repository navigation
docs(api): record the GET /repos 400 for a q or prefix with a NUL byte or invalid UTF-8 - #790
Conversation
…e or invalid UTF-8 Add a row to the deviation table in wire-compatibility.md. GET /repos answers 400 bad_request for a q or prefix with a NUL byte or invalid UTF-8, which the vendored spec ee8092bf does not document. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ Change-Id: Iab8c326bc329a6705f4770d2cf12fac3098caa0d Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ 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. |
|
Codex Review: Didn't find any major issues. Breezy! 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. |
Why
Since #783,
GET /reposanswers 400bad_requestfor aqorprefixthat holds a NUL byte or invalid UTF-8. The vendored upstream specee8092bftypes both as plain strings and documents a 400 only for a pagination cursor that cannot be decoded.docs/reference/http-api.mdstates the 400, but the deviation table indocs/explanation/wire-compatibility.mdhad no row for it. A client that follows the spec does not expect this answer.What changes
One new row in "Known deviations from the vendored spec":
qandprefixare plain strings, and the only documented 400 is a bad cursor.qorprefixanswers 400bad_request("invalid q (want UTF-8 text without NUL)", or the same text forprefix) on/api/reposand/api/v1/repos, on every backend. The only other list route with such a filter,GET .../notes/refs(prefix), has no NUL or UTF-8 check: it compares the raw bytes with the ref names in memory.No code changes.
Verification
handleListRepos(internal/api/handlers.go) checksutf8.ValidStringandstrings.ContainsRune(v, 0)on the trimmedqandprefixand callswriteErr(400, ...)befores.store.ListRepos. BothGET /api/v1/reposandGET /api/reposroute to it (internal/api/api.go).writeErrmaps 400 to the generic codebad_request(genericProblemCodes,internal/api/errors.go).docs/upstream/openapi.yaml, theqandprefixparameters ofGET /api/reposandGET /api/v1/reposhaveschema: {type: string}, and their 400 response says "The supplied pagination cursor could not be decoded." The only other operations with aqorprefixquery parameter are the twonotes/refsroutes (prefix).GET .../notes/refs:rnotesPrefixandhandleListNotesRefs(internal/api/handlers_read_notes.go) matchprefixwithstrings.HasPrefixover the ref list in memory, with no UTF-8 or NUL check. Aprefixthat starts withrefs/outsiderefs/notes/answers 400 under a separate rule. perf(meta): lower a repo list filter once per query on PostgreSQL #785 added no new check.q=e2e\x00b,prefix=e2e-\xff,q=a\xffbandprefix=acme\x00each answered 400,application/problem+json, codebad_request, with the detail above, on/api/reposand/api/v1/repos.notes/refswithprefixa\x00b,\xff,refs/notes/\xffandreviews\x00each answered 200 with an empty list.SELECT $1::texton the test PostgreSQL witha\x00band witha\xffbeach failed with SQLSTATE 22021 ("invalid byte sequence for encoding "UTF8"").python3 scripts/check-doc-links.py(broken links: 0) andpython3 scripts/test_check_doc_links.py(80 tests OK) pass.Fixes #788
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high