alibaba/open-code-review · error
file path %q is a directory
Error message
file path %q is a directory
What it means
Type guard in readWorkspaceFileForDiff: after Lstat, the entry is a directory rather than a regular file. This fires when the workspace change list (e.g. untracked entries from git) contains a directory; directory contents are not reviewable as a single file diff, so the read is refused.
Source
Thrown at internal/diff/workspace_file.go:41
fullPath := filepath.Join(repoRoot, relPath)
if !pathutil.WithinBase(repoRoot, fullPath) {
return nil, fmt.Errorf("file path %q is outside repository", relPath)
}
parent, err := filepath.EvalSymlinks(filepath.Dir(fullPath))
if err != nil {
return nil, fmt.Errorf("resolve parent path for %q: %w", relPath, err)
}
if !pathutil.WithinBase(repoRoot, parent) {
return nil, fmt.Errorf("file path %q is outside repository", relPath)
}
info, err := os.Lstat(fullPath)
if err != nil {
return nil, fmt.Errorf("stat file %q: %w", relPath, err)
}
if info.IsDir() {
return nil, fmt.Errorf("file path %q is a directory", relPath)
}
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 {View on GitHub (pinned to 5cf97d0d15)
Solutions
- Review the files inside the directory individually instead of the directory path
- Exclude directories from the workspace change list before requesting diffs
- If git reported the directory (untracked dir), expand it into its constituent files
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/diff/workspace_file.go:41 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/e2ebff606676fc6b.
Report an issue: GitHub.