Repository navigation
fix(file): accept absolute paths and show the server's reason for missing source - #69
Conversation
…sing source - Resolve an absolute path against the git root when the repository is auto-detected; refuse a path outside the repository before any request. - "Source not available (...)" now shows the server's message via errorReason() instead of the client's static status name. - These were review-round-2 fixes left uncommitted when #68 merged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 6 |
| Duplication | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
👀 Worth a closer look
Two medium-severity portability issues remain in path validation: cross-drive paths may bypass the outside-repository check on Windows, and symlinked paths inside the repository may be rejected. These do not indicate a general acceptance-criteria gap, but they warrant review for cross-platform correctness.
Test suggestions
- Resolve an absolute path inside the Git repository to a repository-relative path.
- Reject relative and absolute paths outside the detected repository.
- Keep explicit-repository paths repository-relative.
- Display the server's message when source retrieval fails.
- Continue rendering issues when source retrieval fails.
TIP How was this review? Give us feedback
| let joined: string; | ||
| if (path.isAbsolute(trimmed)) { | ||
| const root = getGitRepoRoot(); | ||
| joined = root ? path.relative(root, trimmed).split(path.sep).join("/") : ".."; |
There was a problem hiding this comment.
🟡 MEDIUM RISK
An absolute path through a symlink to the repository is rejected even when it names a file inside the repository. Consider resolving symlink aliases before comparing the path with the git root.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| } else { | ||
| joined = path.posix.join(getCwdRepoRelativePath(), trimmed); | ||
| } | ||
| if (joined === ".." || joined.startsWith("../")) { |
There was a problem hiding this comment.
🟡 MEDIUM RISK
On Windows, an absolute path on another drive is not rejected as outside the repository because path.relative returns an absolute path rather than ../.... Consider rejecting an absolute joined result as well.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
Follow-up to #68: these review fixes were finished locally but not pushed before #68 merged.
Changes
codacy file /abs/path/to/repo/src/a.tsis resolved against the git root (shell completion and editors pass absolute paths). A local path that ends up outside the repository (../../x.ts,/etc/passwd) is refused before any request.Source not available (…)now shows the server's message viaerrorReason(err), not the generated client's static status name (e.g.Payload Too Large).SPECS/commands/file.md,src/commands/AGENTS.md,SPECS/README.mdchangelog.filecommand is unreleased, so the existingfile-command.mdchangeset is extended rather than adding a separate patch.Tests
+2 tests in
file.test.ts(absolute path, outside-repo refusal) and the source-error test updated to the server's reason.tsc --noEmitclean, 854/854 passing.🤖 Generated with Claude Code