alibaba/open-code-review · error
read symlink %q: %w
Error message
read symlink %q: %w
What it means
os.Readlink failed on an entry that Lstat reports as a symlink — it disappeared between listing and reading, or readlink was denied. For symlinks, the link target string itself is returned as the 'content' so the diff shows the change of target; that read is what failed.
Source
Thrown at internal/diff/workspace_file.go:46
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 {
return nil, fmt.Errorf("read file %q: %w", relPath, err)
}
return content, nil
}
View on GitHub (pinned to 5cf97d0d15)
Solutions
- Check the wrapped error — the symlink may be dangling or unreadable
- Remove or repair the broken symlink; note that for valid symlinks the link target itself is returned as content, so no target read is attempted
- Ensure filesystem permissions allow readlink
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/diff/workspace_file.go:46 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/84a01832eaf488cc.
Report an issue: GitHub.