alibaba/open-code-review · error

resolve file %q: %w

Error message

resolve file %q: %w

What it means

filepath.EvalSymlinks failed while resolving the file itself (after parent checks passed), or the resolved file — a regular path whose final component is a symlink target — fell outside the repo. Prevents a symlink inside the repo from pointing at a file outside it and having its contents read into the diff.

Source

Thrown at internal/diff/workspace_file.go:53

	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

  1. Check the wrapped error for why EvalSymlinks failed (typically a broken symlink to a nonexistent target)
  2. Repair or remove the broken symlink
  3. If the target exists outside the repo, the subsequent WithinBase check will reject it — that is expected
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/diff/workspace_file.go:53 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/6dcfc7046414bbd8. Report an issue: GitHub.