{"record":{"id":"4a4d7c583f4f9c20","repo":"can1357/oh-my-pi","slug":"path-not-found-for-line-range-selector-spec-ori","errorCode":null,"errorMessage":"Path not found for line-range selector: ${spec.original}","messagePattern":"Path not found for line-range selector: (.+?)","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/grep.ts","lineNumber":1080,"sourceCode":"\t\t\t\t\t// archive entries are keyed by scratch path, URL entries by read-cache\n\t\t\t\t\t// content path, and ordinary files by their resolved filesystem path.\n\t\t\t\t\tfor (let idx = 0; idx < pathSpecs.length; idx++) {\n\t\t\t\t\t\tconst spec = pathSpecs[idx];\n\t\t\t\t\t\tif (!spec.ranges) continue;\n\t\t\t\t\t\tif (virtualInputIndexes.has(idx)) continue;\n\t\t\t\t\t\tconst resolved = internalResolution.resolvedPathsByInput[idx];\n\t\t\t\t\t\tif (!resolved) continue;\n\t\t\t\t\t\tconst materializedExternalPath = materializedExternalPaths.get(spec.clean);\n\t\t\t\t\t\tif (materializedExternalPath) {\n\t\t\t\t\t\t\tmergeRangesInto(rangesByAbsPath, path.resolve(materializedExternalPath), spec.ranges);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (resolved === spec.clean && !archiveDisplayMap.has(resolved)) {\n\t\t\t\t\t\t\t// Non-archive entry; ensure the cleaned path resolves to a regular file.\n\t\t\t\t\t\t\tconst absKey = path.resolve(resolveReadPath(resolved, this.session.cwd));\n\t\t\t\t\t\t\tconst stats = await stat(absKey).catch(() => null);\n\t\t\t\t\t\t\tif (!stats) {\n\t\t\t\t\t\t\t\tthrow new ToolError(`Path not found for line-range selector: ${spec.original}`);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (!stats.isFile()) {\n\t\t\t\t\t\t\t\tthrow new ToolError(\n\t\t\t\t\t\t\t\t\t`Line-range selector requires a single file: ${spec.original} is a directory`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmergeRangesInto(rangesByAbsPath, absKey, spec.ranges);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmergeRangesInto(rangesByAbsPath, path.resolve(resolved), spec.ranges);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// When the only input was an archive selector, surface that selector instead\n\t\t\t\t\t// of the temp scratch path the resolver substituted in.\n\t\t\t\t\tconst physicalScopePath =\n\t\t\t\t\t\tsearchablePaths.length === 1 && archiveDisplayMap.get(searchPath)\n\t\t\t\t\t\t\t? (archiveDisplayMap.get(searchPath) as string)\n\t\t\t\t\t\t\t: scope.scopePath;\n\t\t\t\t\tscopePath = internalResolution.virtualScopePath","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/grep.ts#L1062-L1098","documentation":"A line-range selector (e.g. `file.ts:10-20` as the grep path) resolved to a path that does not exist on disk. Before applying ranges, the tool stats the cleaned path and throws this if the stat fails, differentiating \"path not found\" from the directory case that follows.","triggerScenarios":"grep with a path like `src/app.ts:5-10` where src/app.ts does not exist (typo, wrong cwd, file deleted/moved, wrong branch checked out).","commonSituations":"See trigger scenarios.","solutions":["Verify the file path exists relative to the session cwd (ls or read the file first)","Remove the :ranges suffix and grep the directory to confirm the correct file name","Fix the working directory or use an absolute path in the selector"],"exampleFix":"// before\nawait grep({ pattern: \"TODO\", path: \"src/ap.ts:1-50\" });\n// after\nawait grep({ pattern: \"TODO\", path: \"src/app.ts:1-50\" });","handlingStrategy":"validation","validationCode":"import * as fs from \"node:fs\";\nconst [file] = spec.split(\":\");\nif (!fs.existsSync(file) || !fs.statSync(file).isFile()) throw new Error(`No such file: ${file}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the file exists (read or ls) before attaching :start-end ranges","Check the session cwd matches where your relative paths resolve"],"tags":["grep","path-not-found","line-range"],"backgroundTag":"path-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}