Repository navigation
🤖 fix: trust only Coder's own 404 on the CoderAIProvider create lookups - #350
Merged
Merged
Conversation
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>
Codex Review SummaryThis 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. |
Member
Author
|
@codex security review |
🛡️ 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
CoderAIProvidercreate 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 ininternal/controller/coderaiprovider_create.go: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 withenabled: false, so it did not use the key.confirmRejectedCreate). Such a 404 cleared the marker in the same way.What
Both lookups use
isCoderResourceNotFound: a 404 whose message is Coder's fixedResource not found or you do not have access to this resource. Any other answer falls through to the existing waits. The lookup waits withCoderUnavailable(30 s), keeps the marker and sends no create. After a rejected create, the object waits withConfirmingRejectedCreateand keeps the marker.Docs nit from #338: the credential kill switch paragraph in
docs/how-to/manage-ai-providers.mdnow 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 withCoder can still send the key.Tests
TestCoderAIProviderCreateLookupNotCoder404: an HTML 404 andRoute not found.on the name lookup, for a new create and for a pending create whose create committed. Each one waits withCoderUnavailable, sends no create, and a pending create keeps its marker. The next reconcile isReady, 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 withCoderRejected, and the create is not sent again.Mutation checks (each one breaks a named test, then I reverted it):
isCoderNotFoundback 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-referencewith no diff, andmake docs-check. Before the rebase, two runs ofmake testand 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