Skip to content

feat(api): name invalid fields from the single-field body validators - #443

Merged
ThomasK33 merged 2 commits into
mainfrom
api-352-invalid-validators
Oct 13, 2026
Merged

ThomasK33 merged 2 commits into
mainfrom
api-352-invalid-validators

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

The single-field body validators on upstream's ValidationProblemDetails routes now name their fields in invalid_params. This is PR 5, the last PR of the plan in #352 (issuecomment-6143529650). PR 4 (#436) added invalid_params for decode failures. The PR stays under 500 lines (315), so it needs no split by route family.

Which checks name a field

Route family name reason
Repo create, PATCH, fork, sync create default_branch, base_repo.default_branch is required, is not a valid branch name
Fork and copy base_repo.name, base_repo.auth.token is required / is required for a copy
Sync create (base_repo form) base_repo.owner, base_repo.name, base_repo.provider, base_repo.operation, base_repo.upstream_host is required, is not supported, must be sync or fork, is not a valid host, is denied by the sync egress policy
Sync create (upstream form) upstream.provider, upstream.owner, upstream.name, upstream.access, upstream.host the same, plus must be app or public, must be public
Branches and tags target_branch, name (tag), ref must be a valid branch name, must be a valid tag name, is required
Git credentials password, id is required, is a reserved value
Grep query.pattern, context.before / context.after, limits.max_lines, limits.max_matches_per_file, pagination.limit, pagination.cursor, paths.N is required, must be at least 0, must be between 1 and 2000, must be at least 1, is not a valid cursor, must be a non-empty path
Archive max_blob_size, include_globs.N / exclude_globs.N, archive.prefix must be at least 0, must be a non-empty glob, must be a relative path inside the archive

A check that finds several empty fields names each one. For example, {"upstream":{"provider":"github"}} gives two items, upstream.owner and upstream.name.

These name no field: rules across fields (base_repo and upstream cannot both be set, force requires target_branch, "one of base_ref, base_branch or preferred_base"), query parameters (including a default_branch query override), and result-envelope bodies (tier 3 in #352). Delete-branch's name is also left out, because it can come from the query or the body.

Review follow-ups from PR 4 included here

  • One reason for a non-object member: the strict checker now says must be an object, like type errors. The message text is unchanged.
  • jsonKind reports must be a string for types that decode from a JSON string (encoding.TextUnmarshaler, []byte). A mutation check fails the new time.Time and []byte cases.
  • The notes read 404 "object_ref does not resolve to a commit" now carries ref_not_found, from the PR 3 advisory.

What stays the same

error and detail text, status codes, code, and the application/json content type. validateSyncBaseRepo and parseUpstreamConfig now return errors in place of message strings, with the same messages.

Tests

  • TestInvalidParamsOnValidators (full server, pg and sqlite): 28 cases across the route families above, each asserting the exact item list, plus the negative controls (query parameter, both forms, force without target).
  • assertProblemFields still checks the member set and item shape on every full-server plain-error assertion.

Dogfood

The same requests ran on a real local-mode server (SQLite + files) built from origin/main (66f5c32) and from this branch (b2089fd), then through the stable Go and TS SDKs (1.17.1). The only difference is invalid_params on the five single-field failures. The cross-field rule carries none, and SDK output is identical. The clips are real-time asciinema replays rendered with agg.

origin/main: no invalid_params on validator 400s

This branch: invalid_params on the single-field checks, none on the cross-field rule, SDK output unchanged

pr5-ab.mp4

Docs: docs/reference/http-api.md (Errors) and the RFC 9457 row of docs/explanation/wire-compatibility.md.

Refs #352


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

Refs #352

Change-Id: I800425256699e5b867adff6a622f3bb338fb052d
Signed-off-by: Thomas Kosiewski <tk@coder.com>
…types

Change-Id: Iaeb0a35a1cd444c3b334ffac03ec57d04b423ac3
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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-10-13T17:11:19.522819Z b2089fd Manual request
🔒 Security Review ✅ Completed 2026-10-13T17:10:07.071273Z b2089fd Manual request
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: b2089fd248

View security finding report

Only the user who started this review can view the report in Codex.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: b2089fd248

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

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit e1beeeb Oct 13, 2026
8 of 9 checks passed
@ThomasK33
ThomasK33 deleted the api-352-invalid-validators branch October 13, 2026 18:07
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