Repository navigation
fix(coderd/x/chatd/chattool)!: fail closed when the plan path cannot be resolved - #30983
Conversation
…e resolved ensurePlanPathResolvesToItself treated a 404 from the agent's resolve-path endpoint as success, so plan turns kept writing on agents built before that endpoint existed, without the symlink guard. Coder does not support coderd and agents on different versions, so drop the bypass: every ResolvePath error now fails the write_file or edit_files call. Replace the two tests that expected a write after a 404, and the test-only statusError type they used, with 404 and 500 rows built with codersdk.NewError next to the symlink case.
|
@codex review
|
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. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Both plan path rows used SDK status errors, so a guard that let errors without a status code through still passed. Add a row with a connection error to the write_file and edit_files tables.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Removes the 404 bypass from the plan-turn symlink guard in
write_fileandedit_files.ensurePlanPathResolvesToItselftreated a 404 from the agent'sresolve-pathendpoint as success, so a plan turn on an agent without that endpoint wrote the plan file with no symlink check. Now everyResolvePatherror fails the tool call. The PR deletes the status predicate and itsnet/httpimport, the two tests that expected a write after a 404, and the test-onlystatusErrorfile. The PR adds 77 lines and removes 147.Behavior change, approved by Mike: an agent too old to serve the
resolve-pathendpoint can no longer write plan files during plan turns. The tool returnsresolve plan path: ...instead. The endpoint arrived with plan mode in #24236. Coder does not support mixed coderd and agent versions, and upgrades happen in maintenance windows.Why it is safe: the agent's
resolve-pathhandler never answers 404. It returns 400 for a relative path, 403 for a permission error, and 500 for other errors, and it resolves a path whose last components do not exist yet, such as a new plan file. So a 404 means that the route is missing.codersdk.NewError, and a connection error without a status code. No row expects a write, and the strict gomock controller fails on anyWriteFileorEditFilescall.go test -overlay), the 404 row fails for both tools.ResolvePatherror fails all three error rows for both tools. Onmain, the wholechattoolpackage passes with that mutant.Review focus: the behavior change. Only
write_fileandedit_filescall the guard.propose_plandoes not callResolvePath, and this PR does not change it.Validation:
go test ./coderd/x/chatd/chattool -count=1passes,go vet ./coderd/x/chatd/chattoolis clean, and the pre-commit hook passed.