Skip to content

fix(coderd/x/chatd/chattool)!: fail closed when the plan path cannot be resolved - #30983

Merged
ibetitsmike merged 2 commits into
mainfrom
mike/chattool-plan-path-fail-closed
Oct 27, 2026
Merged

ibetitsmike merged 2 commits into
mainfrom
mike/chattool-plan-path-fail-closed

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Removes the 404 bypass from the plan-turn symlink guard in write_file and edit_files. ensurePlanPathResolvesToItself treated a 404 from the agent's resolve-path endpoint as success, so a plan turn on an agent without that endpoint wrote the plan file with no symlink check. Now every ResolvePath error fails the tool call. The PR deletes the status predicate and its net/http import, the two tests that expected a write after a 404, and the test-only statusError file. The PR adds 77 lines and removes 147.

Behavior change, approved by Mike: an agent too old to serve the resolve-path endpoint can no longer write plan files during plan turns. The tool returns resolve 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-path handler 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.

  • In each tool's tests, the symlink case is now a table with three more rows: a 404 and a 500 built with codersdk.NewError, and a connection error without a status code. No row expects a write, and the strict gomock controller fails on any WriteFile or EditFiles call.
  • With the old resolver (go test -overlay), the 404 row fails for both tools.
  • A mutant that ignores every ResolvePath error fails all three error rows for both tools. On main, the whole chattool package passes with that mutant.
  • A mutant that ignores only errors without a status code, such as a dropped connection, fails the connection error row for both tools. Without that row, both tools' tests pass with it.
  • The success, shared plan path, and mixed-path tests do not change and pass.

Review focus: the behavior change. Only write_file and edit_files call the guard. propose_plan does not call ResolvePath, and this PR does not change it.

Validation: go test ./coderd/x/chatd/chattool -count=1 passes, go vet ./coderd/x/chatd/chattool is clean, and the pre-commit hook passed.

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

…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.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 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-27T03:05:37.331420Z be5909d 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 82375288cc

ℹ️ 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".

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".

@ibetitsmike ibetitsmike changed the title fix(coderd/x/chatd/chattool): fail closed when the plan path cannot be resolved fix(coderd/x/chatd/chattool)!: fail closed when the plan path cannot be resolved Oct 18, 2026
@github-actions github-actions Bot added the release/breaking This label is applied to PRs to detect breaking changes as part of the release process label Oct 18, 2026
@ibetitsmike
ibetitsmike marked this pull request as ready for review October 19, 2026 12:15
@linear-code

linear-code Bot commented Oct 21, 2026

Copy link
Copy Markdown

CODAGT-1445

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.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: be5909d478

ℹ️ 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".

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".

@ibetitsmike
ibetitsmike merged commit 70b1e47 into main Oct 27, 2026
31 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chattool-plan-path-fail-closed branch October 27, 2026 15:16
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants