Repository navigation
🤖 fix: trust only Coder's own 404 when deleting AI Gateway keys - #341
Merged
Merged
Conversation
Change-Id: I9e7b6f5ea04db940c6bd982d0a861a9a811ee0f6 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.
K10a of #156: a gate before activation. When the controller deletes an AI Gateway key, only Coder's own 404 now proves that the key is gone. The controller is still unregistered. K10 (activation) follows on top of this branch.
What changes
deleteOwnKeyanddeleteKeys) used to accept any 404 exceptRoute not found.. An HTML 404 from a proxy, or any other 404, counted as "the key is gone". The controller then dropped a retiring key from status, or released the finalizer, while the key could still work. These calls now useisCoderResourceNotFound(from 🤖 fix: check a CoderAIProvider's provider ID before Coder calls, and trust only Coder's own delete 404 #325). It accepts only Coder'sResource not found or you do not have access to this resourceanswer, whichDELETE /api/v2/ai-gateway/keys/{key}sends for a missing key (enterprise/coderd/aigatewaykeys.go:178-180in v2.37.3). Any other 404 isCoderUnavailableand retries.Route not found.is still theNotSupportedstall, as before.coderRouteMissingis gone.listedKeyIDs), next to the key IDs from status.Tests
TestCoderAIGatewayKeyProxyNotFoundDeletesNothing: an HTML 404 on a sweep DELETE keeps the orphan, and the next reconcile deletes it. An HTML 404 on a retire DELETE keeps the key inretiringKeys, and the next reconcile deletes it.TestCoderAIGatewayKeyDeleteRetrieshas a new "proxy 404" case: the finalizer stays, withCoderUnavailableand a 60 s requeue, and the next reconcile releases it.TestCoderAIGatewayKeyDeleteWithControlPlaneGoing: in the failing namespace-deletion case, the release log names an orphan that only the pass's LIST knows.TestCoderAIGatewayKeyRearmKeepsAnswerMismatchGate(item t).Mutations that the tests catch:
isCoderNotFound(any 404) indeleteOwnKey;isCoderNotFoundindeleteKeys;Size: 130 lines added and 34 removed, of which about 95 are tests.
Local gates on the head:
make verify-vendor,make build,make lint,make test,make test-integration.go tool govulncheck ./....go test -race ./internal/controller/....make codegen,make build-installerandmake docs-referenceleave no drift.Refs #156
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$136.24