Skip to content

fix(tools): prevent EACCES errors from absolute paths in tool calls (#11208)#11247

Open
randomizedcoder wants to merge 1 commit intoRooCodeInc:mainfrom
randomizedcoder:fix/11208-retry-and-path-handling
Open

fix(tools): prevent EACCES errors from absolute paths in tool calls (#11208)#11247
randomizedcoder wants to merge 1 commit intoRooCodeInc:mainfrom
randomizedcoder:fix/11208-retry-and-path-handling

Conversation

@randomizedcoder
Copy link

@randomizedcoder randomizedcoder commented Feb 6, 2026

Related GitHub Issue

Closes: #11208

Roo Code Task Context (Optional)

N/A

Description

This PR fixes the EACCES permission denied errors that occur when LLMs provide absolute paths (like /plans) in tool calls during streaming.

Root Cause: When path.resolve(task.cwd, "/plans") is called with an absolute path, it returns /plans directly, bypassing the workspace directory entirely. This causes filesystem operations to attempt creating directories at the root level.

Key Implementation Details:

  1. Shared path normalization (src/utils/pathUtils.ts):

    • Added normalizeToolPath() with 5-step validation
    • Converts absolute paths to workspace-relative using VS Code API
    • Rejects paths that escape workspace via ../ or resolve outside cwd
  2. Error suppression in BaseTool (src/core/tools/BaseTool.ts):

    • PartialExecutionState discriminated union (idle/streaming/erroring)
    • Per-task state isolation via WeakMap<Task, State>
    • notifyPartialError(): logs first error, suppresses identical repeats
    • shouldSkipDueToPathError(): fast-path guard skips expensive work on known-bad paths
  3. Updated all file-writing tools to use new per-task signatures:

    • hasPathStabilized(task, path)
    • resetPartialState(task)

Also includes (required for test infrastructure):

  • Upgrade turbo ^2.5.6 → ^2.8.3
  • Upgrade node engine 20.19.2 → 20.20.0
  • Pull flake.nix/flake.lock from nix branch ( still waiting for the nix PR merge )

Test Procedure

New tests added (47 tests in 2 files):

  1. src/utils/__tests__/pathUtils.spec.ts - Path normalization tests:

    • Valid paths (simple, nested, normalized, absolute within workspace)
    • Invalid paths (../ traversal, absolute outside workspace like /plans)
    • Edge cases (empty segments, dots, spaces, special characters)
  2. src/core/tools/__tests__/BaseTool.spec.ts - Error suppression tests:

    • Per-task state isolation
    • Error suppression (first logged, repeats suppressed)
    • Fast-path guard behavior
    • State recovery after reset

To run new tests only:

cd src && pnpm vitest run utils/__tests__/pathUtils.spec.ts core/tools/__tests__/BaseTool.spec.ts

Full test suite passes: 370 files, 5461 tests

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - No UI changes

Documentation Updates

I'm not sure if this need extra documentation. Happy for feedback.

Additional Notes

The fix addresses PR #11209's approach but extends it to also handle the handlePartial() streaming path, which is where the repeated errors actually occur during LLM streaming.

Get in Touch

N/A


Important

Fixes EACCES errors by normalizing paths to workspace-relative and adds error suppression for repeated path errors in tool calls.

  • Behavior:
    • Fixes EACCES errors by normalizing absolute paths to workspace-relative in normalizeToolPath() in pathUtils.ts.
    • Implements error suppression for repeated path errors in BaseTool.ts.
  • Tools:
    • Updates WriteToFileTool, EditFileTool, SearchReplaceTool, SearchAndReplaceTool, and ApplyDiffTool to use normalizeToolPath().
    • Adds path stabilization checks and error handling improvements in BaseTool.ts.
  • Tests:
    • Adds tests for path normalization in pathUtils.spec.ts.
    • Adds tests for error suppression and path handling in BaseTool.spec.ts and writeToFileTool.spec.ts.
  • Misc:
    • Updates Node.js version to 20.20.0 in package.json.

This description was created by Ellipsis for bdae65b. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. bug Something isn't working labels Feb 6, 2026
@randomizedcoder
Copy link
Author

@roomote Pull request #11247 build seems to be failing on Windows (Windoze) operating system. This is likely because I had to update package.json. Can you see the errors on the Windows build and adjust the packaging? ... If we switch to building with Nix this won't happen.

@roomote
Copy link
Contributor

roomote bot commented Feb 6, 2026

Fixaroo Clock   See task

Fixed the 12 failing Windows tests in pathUtils.spec.ts by making all path construction platform-agnostic (using path.resolve/path.normalize/path.join instead of hardcoded Unix-style paths), and reverted the node engine version back to 20.19.2 to match the CI default. All local checks passed.

View commit | Revert commit

@randomizedcoder
Copy link
Author

oh wow. nice work fixaroo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] EACCES: permission denied, mkdir '/plans'Details

1 participant