Skip to content

🤖 fix: trust only Coder's own 404 on the CoderAIProvider create lookups - #350

Merged
ThomasK33 merged 1 commit into
mainfrom
ai-provider-create-404
Oct 14, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
ai-provider-create-404

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

The CoderAIProvider create path now trusts only Coder's own 404 on its name lookups, as the delete path (#325) and the sync and disable paths (#335) already do.

Fixes #338
Refs #154

Why

A 404 that Coder did not send (an HTML page from a proxy, or Coder's Route not found. for a wrong base URL) counted as "no such provider" in two places in internal/controller/coderaiprovider_create.go:

  1. The name lookup before a create, which also confirms a pending create (createOrConfirm). With a create marker, such a 404 could clear the marker of a create that committed. A delete at that point released the finalizer without a delete in Coder, and Coder kept a provider that holds the key. Coder created that provider with enabled: false, so it did not use the key.
  2. The read after a rejected create (confirmRejectedCreate). Such a 404 cleared the marker in the same way.

What

Both lookups use isCoderResourceNotFound: a 404 whose message is Coder's fixed Resource not found or you do not have access to this resource. Any other answer falls through to the existing waits. The lookup waits with CoderUnavailable (30 s), keeps the marker and sends no create. After a rejected create, the object waits with ConfirmingRejectedCreate and keeps the marker.

Docs nit from #338: the credential kill switch paragraph in docs/how-to/manage-ai-providers.md now says that a failed Coder call for the disable, including a 404 that Coder did not send, retries every 30 seconds with a message that starts with Coder can still send the key.

Tests

  • TestCoderAIProviderCreateLookupNotCoder404: an HTML 404 and Route not found. on the name lookup, for a new create and for a pending create whose create committed. Each one waits with CoderUnavailable, sends no create, and a pending create keeps its marker. The next reconcile is Ready, with one provider in Coder.
  • TestCoderAIProviderRejectedCreateNotCoder404: after a 400 create answer, a non-Coder 404 on the confirmation read keeps the marker (ConfirmingRejectedCreate). The next read stalls with CoderRejected, and the create is not sent again.
  • The existing name-conflict test now injects Coder's own 404 message.

Mutation checks (each one breaks a named test, then I reverted it): isCoderNotFound back on the name lookup, and on the read after a rejected create.

Local gates on the pushed tree, exit 0 each: make verify-vendor, make test, make test-integration, make build, make lint, go tool govulncheck ./..., go test -race ./internal/controller/, make codegen manifests build-installer docs-reference with no diff, and make docs-check. Before the rebase, two runs of make test and one race run failed with envtest timeouts (timeout waiting for process kube-apiserver to stop) while the host load average was about 130. Those runs failed outside this change, and all gates pass on this tree.


Generated with mux • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $129.14

A 404 that Coder did not send on the name lookup before a create, or on
the read after a rejected create, could clear the create marker of a
create that committed. Both lookups now need Coder's own 404, and any
other answer keeps the marker and waits with CoderUnavailable. The how-to
also says that a failed disable call retries every 30 seconds.

Fixes #338

Change-Id: I184e01149e0a71e2849d0437754a7145bb786599
Signed-off-by: Thomas Kosiewski <tk@coder.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-14T09:44:32.069850Z aa7f527 PR opened
🔒 Security Review ✅ Completed 2026-10-14T09:48:00.959695Z aa7f527 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.

@ThomasK33

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: aa7f527628

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 Oct 14, 2026
Merged via the queue into main with commit 3372652 Oct 14, 2026
13 checks passed
@ThomasK33
ThomasK33 deleted the ai-provider-create-404 branch October 14, 2026 10:26
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.

CoderAIProvider create path: trust only Coder's own 404 on name lookups

1 participant