{"record":{"id":"80ac56e9d008dab3","repo":"continuedev/continue","slug":"findandreplacemissingfilepath","errorCode":"FindAndReplaceMissingFilepath","errorMessage":"filepath (string) is required","messagePattern":"filepath \\(string\\) is required","errorType":"validation","errorClass":"ContinueError","httpStatus":null,"severity":"error","filePath":"core/edit/searchAndReplace/validateArgs.ts","lineNumber":10,"sourceCode":"import { IDE } from \"../..\";\nimport { ContinueError, ContinueErrorReason } from \"../../util/errors\";\nimport { resolveRelativePathInDir } from \"../../util/ideUtils\";\n\nexport async function validateSearchAndReplaceFilepath(\n  filepath: unknown,\n  ide: IDE,\n) {\n  if (!filepath || typeof filepath !== \"string\") {\n    throw new ContinueError(\n      ContinueErrorReason.FindAndReplaceMissingFilepath,\n      \"filepath (string) is required\",\n    );\n  }\n  const resolvedFilepath = await resolveRelativePathInDir(filepath, ide);\n  if (!resolvedFilepath) {\n    throw new ContinueError(\n      ContinueErrorReason.FileNotFound,\n      `File ${filepath} does not exist`,\n    );\n  }\n  return resolvedFilepath;\n}\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/edit/searchAndReplace/validateArgs.ts#L1-L24","documentation":"Thrown by validateSearchAndReplaceFilepath when the filepath argument is missing, empty, or not a string. It is the first check before path resolution, so any non-string filepath fails here rather than deep in file I/O.","triggerScenarios":"Calling search/replace tools with filepath: undefined, filepath: null, filepath: 123, or filepath: \"\" — commonly a destructuring typo or an unset variable.","commonSituations":"LLM tool calls omitting the filepath field; callers passing a URI object instead of its string path; optional chaining upstream yielding undefined.","solutions":["Ensure filepath is a non-empty string before calling","If you hold a Uri object, pass uri.path or the documented string form","Validate required fields up front in your own tool wrapper"],"exampleFix":"// before\nawait findAndReplace({ filepath: uri, ... });\n// after\nawait findAndReplace({ filepath: String(uri.path ?? uri), ... });","handlingStrategy":"type-guard","validationCode":"if (typeof filepath !== 'string' || filepath.length === 0) throw new TypeError('filepath string required');","typeGuard":"const isFilepath = (f: unknown): f is string => typeof f === 'string' && f.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Destructure with defaults and assert presence","Pass uri.path for URI objects","Add required-field checks in tool wrappers"],"tags":["filepath","validation","required-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}