{"record":{"id":"0ee3a3cbf2981784","repo":"alibaba/open-code-review","slug":"resolve-parent-path-for-q-w","errorCode":null,"errorMessage":"resolve parent path for %q: %w","messagePattern":"resolve parent path for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/diff/workspace_file.go","lineNumber":30,"sourceCode":")\n\nfunc readWorkspaceFileForDiff(repoDir, relPath string) ([]byte, error) {\n\trepoRoot, err := pathutil.CanonicalPath(repoDir)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolve repository path %q: %w\", repoDir, err)\n\t}\n\tif filepath.IsAbs(relPath) {\n\t\treturn nil, fmt.Errorf(\"file path %q must be relative, not absolute\", relPath)\n\t}\n\n\tfullPath := filepath.Join(repoRoot, relPath)\n\tif !pathutil.WithinBase(repoRoot, fullPath) {\n\t\treturn nil, fmt.Errorf(\"file path %q is outside repository\", relPath)\n\t}\n\n\tparent, err := filepath.EvalSymlinks(filepath.Dir(fullPath))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"resolve parent path for %q: %w\", relPath, err)\n\t}\n\tif !pathutil.WithinBase(repoRoot, parent) {\n\t\treturn nil, fmt.Errorf(\"file path %q is outside repository\", relPath)\n\t}\n\n\tinfo, err := os.Lstat(fullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"stat file %q: %w\", relPath, err)\n\t}\n\tif info.IsDir() {\n\t\treturn nil, fmt.Errorf(\"file path %q is a directory\", relPath)\n\t}\n\tif info.Mode()&os.ModeSymlink != 0 {\n\t\ttarget, err := os.Readlink(fullPath)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"read symlink %q: %w\", relPath, err)\n\t\t}\n\t\treturn []byte(target), nil","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/diff/workspace_file.go#L12-L48","documentation":"filepath.EvalSymlinks failed on the file's parent directory while resolving symlinks to verify containment — typically the parent directory does not exist (file deleted after git status) or a permission/traversal error occurred. The relative path and OS error are wrapped for diagnosis.","triggerScenarios":"Thrown at internal/diff/workspace_file.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error — usually the file or a parent directory does not exist (broken symlink or dangling path)","Recreate the missing parent directory or remove the broken symlink","Ensure the path resolves on the local filesystem before diffing it as a workspace change"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}