alibaba/open-code-review · error

read file %q: %w

Error message

read file %q: %w

What it means

Final os.ReadFile on the resolved, containment-checked path failed — permission denied, file deleted in a race, or an I/O error. All safety checks passed; this is a plain read failure wrapped with the repo-relative path and OS error.

Source

Thrown at internal/diff/workspace_file.go:60

	}
	if info.Mode()&os.ModeSymlink != 0 {
		target, err := os.Readlink(fullPath)
		if err != nil {
			return nil, fmt.Errorf("read symlink %q: %w", relPath, err)
		}
		return []byte(target), nil
	}

	resolvedPath, err := filepath.EvalSymlinks(fullPath)
	if err != nil {
		return nil, fmt.Errorf("resolve file %q: %w", relPath, err)
	}
	if !pathutil.WithinBase(repoRoot, resolvedPath) {
		return nil, fmt.Errorf("file path %q is outside repository", relPath)
	}
	content, err := os.ReadFile(resolvedPath)
	if err != nil {
		return nil, fmt.Errorf("read file %q: %w", relPath, err)
	}
	return content, nil
}

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Check the wrapped error (ENOENT/EACCES/ EISDIR etc.) to see why the read failed
  2. Verify the file exists and is readable by the current user
  3. If the working tree changed mid-review, refresh the change list and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/diff/workspace_file.go:60 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/2ac56faa6c693d0d. Report an issue: GitHub.