{"record":{"id":"70bacd76ad79b9e8","repo":"lima-vm/lima","slug":"path-is-empty","errorCode":null,"errorMessage":"path is empty","messagePattern":"path is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/mcp/toolset/toolset.go","lineNumber":107,"sourceCode":"\tmcp.AddTool(server, msi.SearchFileContent, ts.SearchFileContent)\n\tmcp.AddTool(server, msi.RunShellCommand, ts.RunShellCommand)\n\treturn nil\n}\n\nfunc (ts *ToolSet) Close() error {\n\tvar err error\n\tif ts.sftp != nil {\n\t\terr = errors.Join(err, ts.sftp.Close())\n\t}\n\tif ts.sftpCmd != nil && ts.sftpCmd.Process != nil {\n\t\terr = errors.Join(err, ts.sftpCmd.Process.Kill())\n\t}\n\treturn err\n}\n\nfunc (ts *ToolSet) TranslateHostPath(hostPath string) (string, error) {\n\tif hostPath == \"\" {\n\t\treturn \"\", errors.New(\"path is empty\")\n\t}\n\tif !filepath.IsAbs(hostPath) {\n\t\treturn \"\", fmt.Errorf(\"expected an absolute path, got a relative path: %#q\", hostPath)\n\t}\n\t// TODO: make sure that hostPath is mounted\n\treturn hostPath, nil\n}\n","sourceCodeStart":89,"sourceCodeEnd":115,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/mcp/toolset/toolset.go#L89-L115","documentation":"TranslateHostPath validates host paths passed to MCP file tools before they reach the VM layer. It rejects an empty hostPath string with 'path is empty' because an empty path can never be translated into a valid guest-side location. It is a fast-fail guard so callers get a clear message instead of downstream file operations failing confusingly.","triggerScenarios":"Calling ListDirectory, ReadFile, WriteFile, Glob, SearchFileContent, or RunShellCommand with an empty path argument (e.g. a variable that was never populated, or an LLM agent emitting \"\"), which all funnel into TranslateHostPath.","commonSituations":"MCP client sends a tool call with the path parameter missing/defaulted to empty string; a script builds a path variable from an unset env var; an agent omits an optional path field that is actually required.","solutions":["Provide a non-empty absolute host path in the tool call argument","Check the calling code for a variable that is empty at call time (unset env var, missing config field)","For agents, ensure the tool schema marks path as required so the model supplies it"],"exampleFix":"// before\nTranslateHostPath(\"\")\n// after\nTranslateHostPath(\"/Users/me/project/file.txt\")","handlingStrategy":"validation","validationCode":"if hostPath == \"\" {\n    return fmt.Errorf(\"cannot call tool: host path is empty\")\n}","typeGuard":null,"tryCatchPattern":"path, err := ts.TranslateHostPath(p)\nif err != nil {\n    if err.Error() == \"path is empty\" {\n        // prompt caller/agent to supply a path\n    }\n    return err\n}","preventionTips":["Mark the path parameter required in tool schemas","Default missing paths to a sensible base directory instead of \"\"","Validate arguments at the MCP client boundary"],"tags":["mcp","path","validation","go"],"backgroundTag":"empty-path-argument","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}