Repository navigation
🤖 fix: trust only Coder's own 404 in the CoderTemplateTest and pool member workspace lookups, and refresh the AI provider how-to - #352
Merged
Conversation
…ember workspace lookups, and refresh the AI provider how-to (#351) Change-Id: Id98fd9f86214f9b90af1bd4b2fe216d5da592218 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.
Two follow-ups after v0.1.4.
CoderTemplateTestand pool member workspace lookups trust only Coder's own 404. A 404 without Coder's message, such as a proxy's HTML page orRoute not found.for a wrong base URL, now makes the controller wait asCoderUnavailable. It keeps the create marker. Before, such a 404 counted as "no workspace":CreateOutcomeUnknown. The test released its finalizer, and the member cleared its marker. Aktt-workspace could then stay in Coder with nothing to clean it up.CoderRejectedrow now says "the create or update request", because the sync PATCH also returns it (🤖 fix: keep the create answer in CoderTemplateTest waits and retry 408/499 on the CoderAIProvider sync #347).Fixes #351
Change
internal/controller/codertemplatetest_confirm.go(confirm read),internal/controller/codertemplatetest_controller.go(name lookup before the create) andinternal/controller/coderworkspacepoolmember_ready.go(confirmPoolMemberCreate):isCoderResourceNotFoundfrom 🤖 fix: check a CoderAIProvider's provider ID before Coder calls, and trust only Coder's own delete 404 #325 replacesisCoderNotFound. Each is a one-line change.internal/controller/fakecoder_test.go: the fake's workspace-by-name 404 now has Coder's own message, "Resource not found or you do not have access to this resource". Without it, every test that reads a missing workspace would wait.docs/how-to/manage-ai-providers.md: the two text fixes above.The pool member controller is not registered yet. It must have this fix before PR 12 of #153 registers it.
Why the message check is safe for Coder's own 404
In Coder v2.37.3, every 404 on
GET /api/v2/users/{user}/workspace/{workspacename}comes fromhttpapi.ResourceNotFound, which has the fixed message (coderd/httpapi/httpapi.go:149-155). This holds for the handler (workspaceByOwnerAndNameincoderd/workspaces.go) and for the route's middleware (httpmw/userparam.go,httpmw/organizationparam.go).Route not found.is Coder's answer to an unknown route (httpapi.go:180).I checked the v0.1.4 facts too: tag
v0.1.4is33726526and has theCoderAIProvidercontroller and CRD. Itsdist/install.yamlstill usesghcr.io/coder/coder-k8s:latest, so the pin advice stays. On GHCR,:latestand:0.1.4have the same digest (sha256:80057d31…).Tests
All three envtests run two cases from
nonCoderNotFounds: an HTML 404 page and a JSON 404Route not found..TestTemplateTestConfirmTrustsOnlyCodersNotFound: after an uncertain create (502) and the full 15-minute settle window, a non-Coder 404 givesRunning/CoderUnavailable. Then Coder's own 404 givesCreateOutcomeUnknown. There is only one create request.TestTemplateTestLookupTrustsOnlyCodersNotFound: a non-Coder 404 on the lookup before the create givesPending/CoderUnavailable, with no marker and no create request. The next reconciles create the workspace.TestPoolMemberConfirmTrustsOnlyCodersNotFound: the same as the first test, for a pool member. The marker stays after the non-Coder 404.Validation
main(322124dc), with the tests and the fake change on top and the controller files frommain: all 6 subtests fail. The confirm tests reachFailed(CreateOutcomeUnknown) instead of waiting. The lookup test reachesRunning(it sent the create) instead ofPending.TestTemplateTest*andTestPoolMember*test passes (98).isCoderNotFound: onlyTestTemplateTestConfirmTrustsOnlyCodersNotFoundfails.isCoderNotFound: onlyTestTemplateTestLookupTrustsOnlyCodersNotFoundfails.isCoderNotFound: onlyTestPoolMemberConfirmTrustsOnlyCodersNotFoundfails.make verify-vendor,make build,make lint,make docs-check,make test,make test-integrationpass. markdownlint and cspell pass on the changed doc.make testrun failed two timing tests ininternal/aggregated/storage, which this PR does not touch:TestTemplatePromoteConfirmation/timeout_before_apply("waited 1.05s … the PATCH budget is 50ms") andTestTemplatePromoteDeadline/slow_re-read_ends_before_the_deadline. The host load was about 50 then. Both tests and a fullmake testpassed on the next run, on the same head.Not in this PR
The pool member's name lookup before the create (
checkCreateincoderworkspacepoolmember_controller.go) still usesisCoderNotFound. It is the pool member twin of the template test lookup above. #351 does not list it. It is dormant and only affects the step before the create.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$85.28