fix: normalize file paths in read tool output #8656

Open
opened 2026-02-16 18:10:30 -05:00 by yindo · 1 comment
Owner

Originally created by @scarf005 on GitHub (Feb 5, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

When the read tool displays file paths outside the worktree, it shows confusing relative paths like:

read ../../../../../../home/scarf/foo/bar/baz.ts

This is hard to understand and makes the output noisy.

Solution

Modify the read tool to check if a file is within the worktree before deciding how to display the path:

  • Inside worktree: Show relative path (e.g., src/tool/read.ts)
  • Outside worktree: Show absolute path (e.g., /home/user/other/file.ts)

This improves UX by showing clean, understandable paths.

Originally created by @scarf005 on GitHub (Feb 5, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem When the read tool displays file paths outside the worktree, it shows confusing relative paths like: ``` read ../../../../../../home/scarf/foo/bar/baz.ts ``` This is hard to understand and makes the output noisy. ## Solution Modify the read tool to check if a file is within the worktree before deciding how to display the path: - **Inside worktree**: Show relative path (e.g., `src/tool/read.ts`) - **Outside worktree**: Show absolute path (e.g., `/home/user/other/file.ts`) This improves UX by showing clean, understandable paths.
Author
Owner

@github-actions[bot] commented on GitHub (Feb 5, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #11703: Potential path traversal in file read/write tools (also involves read tool path normalization)
  • #8313: Path traversal vulnerability via symlinks and cross-drive paths (related to path normalization and symlink resolution)
  • #10643: Worktrees created from bare repos are not recognized (involves worktree path resolution)
  • #11113: Patch tool should fail fast on paths outside workspace (similar logic of determining workspace/worktree boundaries)

Additionally, these related issues suggest ongoing work in path handling across the codebase:

  • #11042: External directory permission does not work on Windows (cross-platform path normalization)
  • #4686: TUI sends absolute local paths causing ENOENT on server side (path normalization between contexts)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Feb 5, 2026): This issue might be a duplicate of existing issues. Please check: - #11703: Potential path traversal in file read/write tools (also involves read tool path normalization) - #8313: Path traversal vulnerability via symlinks and cross-drive paths (related to path normalization and symlink resolution) - #10643: Worktrees created from bare repos are not recognized (involves worktree path resolution) - #11113: Patch tool should fail fast on paths outside workspace (similar logic of determining workspace/worktree boundaries) Additionally, these related issues suggest ongoing work in path handling across the codebase: - #11042: External directory permission does not work on Windows (cross-platform path normalization) - #4686: TUI sends absolute local paths causing ENOENT on server side (path normalization between contexts) Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8656