Skip to content

fix(api): refuse a sync link or credential that git cannot take when it is stored - #892

Merged
ThomasK33 merged 6 commits into
mainfrom
sync-values-at-registration
Nov 16, 2026
Merged

ThomasK33 merged 6 commits into
mainfrom
sync-values-at-registration

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

POST /repos and the git credential routes now refuse a sync value that git cannot take, with 400 and invalid_params, before anything is stored. Since #748 the sync run fails such a link as repository configuration error on every run, so the client learned it only from a failed run.

Value Limit Routes invalid_params
Upstream URL (https://{host}/{owner}/{name}.git, or the host as given when it has a scheme, without trailing /s) 131,070 bytes POST /repos with upstream or a base_repo sync the owner, the name, and the host field when the body sent one, reason must keep the upstream URL at most 131070 bytes
base_repo.auth.token 131,042 bytes POST /repos base_repo.auth.token, must be at most 131042 bytes
username, password 131,042 bytes POST/PUT /repos/git-credentials, POST/PUT /repos/{repo_name}/git-credentials, PUT /repos/{repo_name}/git-credentials/{id} the field, must be at most 131042 bytes
  • One source of truth: the API uses the worker's constants, now exported as sync.MaxUpstreamURLBytes and sync.MaxCredentialBytes. The worker checks (upstreamURLFailure, Worker.upstreamAuth) stay as the backstop for values stored before this change.
  • Order of the items: the URL problem names three fields, and upstream.access (or base_repo.auth.token and base_repo.default_branch) lies between the name and the host in the docs. A problem of such a field joins the URL problem in that place, as addFields does for the required fields, so the items keep the order of the body.
  • When the URL is not checked: an owner, name or host with a problem of its own makes no URL, so only that problem answers.
  • A value over the limit that also holds a NUL is one problem, the NUL, as for idents.
  • Separate, not changed here: a base_repo.auth.token that starts with enc: makes the create answer 500 (main too), while the credential routes answer 400 for the same value. A credential with a CR or LF is stored (201), and then every sync run fails it as configuration; that is the same class as this PR but outside its decision.

Evidence

  • Red on main: TestSyncValuesGitCannotTakeAtRegistration fails on main's handlers (go test -overlay with main's handlers_sync.go and handlers_credentials.go): every over-the-limit case is stored (201/200) instead of 400. On this head it passes, and a link and a credential at the limits are stored. The test pins the literal numbers.
  • Mutants: 12 overlay mutants of the new checks (the URL gates, the default host of a base_repo, the order of the joined items, NUL before length for the password and the token, a URL built without CloneURL) all fail TestSyncValuesGitCannotTakeAtRegistration; a no-op control passes.
  • Lanes: go test -race -tags=openstorage_viewcheck of ./internal/sync/... (92 s at 286cc3c, same sync code as the head) and ./internal/api/... without pg (353 s at 2fb75df) pass. PostgreSQL and S3-WAL rely on CI.
  • lint, vet (linux and darwin), the docs gate and both fingerprint gates pass. The lane-schedule fingerprints are re-recorded: they cover the renamed constants, Worker.upstreamAuth, upstreamURLFailure, and the changed API validators.

Review

  • Independent review of c047b03: PASS with seven P3 points. Six were cases the tests did not pin (ten mutants survived); 9507c48 adds a case for each, and the docs now say how a host with a scheme makes the URL and that a link or credential stored by an older server still meets the run check.
  • Independent review of 9507c48: PASS with five P3 points. 2fb75df adds the two cases still missing (a base_repo bad host next to a long URL, an unsupported provider with a host sent) and the wording fixes. The CR/LF credential gap is listed above as separate.
  • Independent review of 2fb75df: PASS with three P3 points, not fixed here because the Codex reviews of this PR are used up: no case sends an over-limit username next to a short valid password (two mutants survive), internal/api/README.md does not list the new limits, and a comment in gcredValidate says the entry, not the value, must fit MaxCredentialBytes.
  • Merge head: the merge queue dropped 2fb75df when fix(githttp): refuse a push whose old id names no commit #845 re-recorded the lane-schedule fingerprints (conflict in SKILL.md). 33c2441 merges main (main's SKILL.md), and c384208 records the fingerprints again. Outside .agents/ the PR diff is byte for byte the one Codex and the reviews passed at 2fb75df. The sync (66 s) and api (339 s) race lanes pass on the merged tree. This head has no Codex pair: the six Codex requests of this PR are used up.

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

…it is stored

A sync run gives git the upstream URL as one argument and each credential
value as one environment entry. Since #748 a run fails as configuration
when the URL is over 131,070 bytes or a username or password is over
131,042 bytes, but POST /repos and the git credential routes stored such
values, so the client learned it only from a failed run. They now answer
400 with invalid_params, using the worker's constants, which are now
exported (sync.MaxUpstreamURLBytes, sync.MaxCredentialBytes). The run
check stays for values stored before.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

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

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: I8c1967a3e7a4c06c2113400a34401752e86ae5e4
@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 Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-16T15:48:58.917951Z 2fb75df Manual request
🔒 Security Review ✅ Completed 2026-11-16T15:49:41.733757Z 2fb75df 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 Review: Didn't find any major issues. Keep it up!

Reviewed commit: c047b0367a

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: c047b0367a

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.

Ten mutants of the new checks passed the tests: a bad host that would
also make the URL too long, the default host of a base_repo, the
default_branch problem inside the URL problem and its order, an owner,
name, password or token that holds a NUL and is over its limit, and a
host with a path and a trailing slash, at and over the limit. Each now
has a case, and each of those mutants fails. The docs say how a host
with a scheme makes the URL, and that a link or credential stored by an
older server still meets the run check.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: I7788a7e1b1007beaa98be91924b94cfc18cfbe17
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 9507c4835c

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: 9507c4835c

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.

…xt to a long URL

The second review found two branches without a case: a base_repo whose
upstream_host is bad and whose URL would be too long, and an unsupported
provider with a host sent, where the URL is still checked. Both mutants
now fail. The docs say that a host loses all its trailing slashes.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: I244f64c9b45b9ee55c048571a2f4224958435baf
@ThomasK33

Copy link
Copy Markdown
Member Author

@codex review

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 2fb75df1c7

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: 2fb75df1c7

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.

@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 16, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 16, 2026
main got #845, which re-recorded the lane-schedule fingerprints. This
takes main's SKILL.md; the fingerprints are recorded again next.

Signed-off-by: Thomas Kosiewski <tk@coder.com>

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

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

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_

Change-Id: Ia1f99374b8fc08039135fd970a650ad0376ceaa9
@ThomasK33
ThomasK33 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit ee76167 Nov 16, 2026
15 of 16 checks passed
@ThomasK33
ThomasK33 deleted the sync-values-at-registration branch November 16, 2026 17:53
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