read_code answers path_outside_root for a missing file whose directory does not exist #578

Closed
opened 2026-11-12 14:14:07 +01:00 by buildagent · 1 comment
Member

Found by the lead while reviewing a lane of the v0.41.51 train; reproduced on the installed release, 0.41.50 (3d0a584c), in this repository.

Reproduction:

code-index query read_code '{"target":"crates/missing.rs"}'
code-index query read_code '{"target":"nope/missing.rs"}'
code-index query read_code '{"target":"crates/nope/deeper/missing.rs"}'

Actual: the first answers file_not_readable ("No readable file at that path. …"), which is right. The second and third answer path_outside_root with the hint "Paths must be project-relative with no absolute or .. components." Both paths are project-relative and contain no ...

Cause: containment is decided by canonicalizing the parent directory; when that fails because the directory is missing, the failure is reported as a containment violation. #568 fixed the same confusion for reads with rev; the working-tree read still has it. A path component longer than the filesystem's name limit takes the same route.

Expected: a path that is lexically inside the root and does not exist answers file_not_readable, whatever part of it is missing. Containment is still decided on what exists: the deepest existing ancestor is canonicalized, and if it leaves the root (a symlinked directory pointing outside) the answer stays path_outside_root.

Impact: an agent that guesses a path in a directory that does not exist is told its path is malformed, not that the file is missing, and the hint points it away from list_files. Whether file_outline, get_dependencies, list_files and index_coverage share the refusal is being checked in the lane that fixes this.

Found by the lead while reviewing a lane of the v0.41.51 train; reproduced on the installed release, 0.41.50 (3d0a584c), in this repository. **Reproduction:** ``` code-index query read_code '{"target":"crates/missing.rs"}' code-index query read_code '{"target":"nope/missing.rs"}' code-index query read_code '{"target":"crates/nope/deeper/missing.rs"}' ``` **Actual:** the first answers `file_not_readable` ("No readable file at that path. …"), which is right. The second and third answer `path_outside_root` with the hint "Paths must be project-relative with no absolute or `..` components." Both paths are project-relative and contain no `..`. **Cause:** containment is decided by canonicalizing the parent directory; when that fails because the directory is missing, the failure is reported as a containment violation. #568 fixed the same confusion for reads with `rev`; the working-tree read still has it. A path component longer than the filesystem's name limit takes the same route. **Expected:** a path that is lexically inside the root and does not exist answers `file_not_readable`, whatever part of it is missing. Containment is still decided on what exists: the deepest existing ancestor is canonicalized, and if it leaves the root (a symlinked directory pointing outside) the answer stays `path_outside_root`. **Impact:** an agent that guesses a path in a directory that does not exist is told its path is malformed, not that the file is missing, and the hint points it away from `list_files`. Whether `file_outline`, `get_dependencies`, `list_files` and `index_coverage` share the refusal is being checked in the lane that fixes this.
Author
Member

Released in v0.41.52 (7fc7fb20, release run 8656, 15 assets). Verified on the installed Linux x86_64 binaries (code-index 0.41.52 (7fc7fb20)):

read_code target answer
src/missing.rs file_not_readable
nope/missing.rs (directory does not exist) file_not_readable
src/nope/deeper/missing.rs file_not_readable
Cargo.toml/x (a file used as a directory) file_not_readable
a path outside the project path_outside_root
a dangling symlink, and a path through one path_outside_root
Released in [v0.41.52](https://git.h-dv.de/h-dv/code-index/releases/tag/v0.41.52) (`7fc7fb20`, release run 8656, 15 assets). Verified on the installed Linux x86_64 binaries (`code-index 0.41.52 (7fc7fb20)`): | `read_code` target | answer | | :-- | :-- | | `src/missing.rs` | `file_not_readable` | | `nope/missing.rs` (directory does not exist) | `file_not_readable` | | `src/nope/deeper/missing.rs` | `file_not_readable` | | `Cargo.toml/x` (a file used as a directory) | `file_not_readable` | | a path outside the project | `path_outside_root` | | a dangling symlink, and a path through one | `path_outside_root` |
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#578
No description provided.