Skip to content

fix(tool): distinguish directories from missing files in file_read - #2171

Open
lizhengfeng101 wants to merge 3 commits into
mainfrom
fix/file-read-path-errors
Open

lizhengfeng101 wants to merge 3 commits into
mainfrom
fix/file-read-path-errors

Conversation

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Description

file_read used to label workspace directory reads as missing and display a Git tree listing as numbered file contents. It now rejects directories on either comparison side. Compatibility change: reading a directory at a Git revision no longer lists its entries.

A missing-path error identifies the working tree or revision in which the path was checked. Inspection failures retain their own diagnostics. Directory and missing-path calls remain visible as unsuccessful, but repeating them does not consume the consecutive-failure allowance or hide the original reason.

Ordinary committed files still take one Git command to read, including empty files. The tools reference and error example are updated in all six published documentation languages.

How Has This Been Tested?

  • make check and make test (including the race detector).
  • Git and workspace fixtures cover directories, missing paths, empty files, deleted files on both sides, unavailable Git objects, permission errors, cancellation and repository boundaries. A Git trace verifies the one-command success path.
  • Review-task tests check that repeated path errors stay visible without changing the failure streak.
  • The Pages documentation and locale suites passed (43 tests), as did the translation-sync check.
  • GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build ./internal/tool verifies that the workspace path handling compiles for Windows.

AI Assistance

OpenAI Codex CLI (gpt-6.2-astra) assisted with implementation, tests, documentation and PR preparation. OpenCodeReview (gpt-6.2-astra) reviewed the three selected production Go files before commit.

Review Notes

Regression tests cover two cases found in pre-commit review: the root of the synthetic empty tree (. or ./) is a directory, and a workspace path beneath a regular file is missing. The latter is classified only after checking the repository boundary.

The review also noted that a Git submodule entry and a workspace named pipe are not regular files or Git trees. They still follow the generic failure-streak handling; this change does not introduce a new policy for special file types.

Closes #2170.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview · Complete review: 3 of 3 selected files covered

0 findings.

Review info

Reviewed commits: af97d1e87dc3ce119891b7dfa2a08cee31795efb → b13549b4edd82c9a48774d9375e0267da6075074

File Result
internal/reviewtask/tools.go Reviewed
internal/tool/filereader.go Reviewed
internal/tool/file_read.go Reviewed

@MuoDoo MuoDoo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tool): make file_read distinguish directories from missing files

2 participants