{"record":{"id":"b4f3814bde06884c","repo":"lima-vm/lima","slug":"expected-an-absolute-path-got-a-relative-path","errorCode":null,"errorMessage":"expected an absolute path, got a relative path: %#q","messagePattern":"expected an absolute path, got a relative path: %#q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/mcp/toolset/toolset.go","lineNumber":110,"sourceCode":"}\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":92,"sourceCodeEnd":115,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/mcp/toolset/toolset.go#L92-L115","documentation":"TranslateHostPath requires an absolute host path because it must map unambiguously onto a host location shared with the VM. Relative paths are rejected with this error since there is no defined working directory to resolve them against. The offending value is quoted with %#q for easy diagnosis.","triggerScenarios":"Calling ListDirectory, ReadFile, WriteFile, Glob, SearchFileContent, or RunShellCommand with a path like \"foo.txt\", \"./dir\", or \"~/docs\" — any value for which filepath.IsAbs is false.","commonSituations":"Passing a relative path from a project-local config; using \"~\" which is not expanded by the library; an agent generating shorthand paths; code that previously ran with a different cwd now producing relative paths.","solutions":["Convert the path with filepath.Abs before calling, anchored to your working directory","Expand \"~\" to the home directory yourself (os.UserHomeDir) before passing","Store absolute paths in configuration consumed by the MCP tools"],"exampleFix":"// before\nTranslateHostPath(\"./data\")\n// after\nabs, _ := filepath.Abs(\"./data\")\nTranslateHostPath(abs)","handlingStrategy":"validation","validationCode":"if !filepath.IsAbs(hostPath) {\n    abs, err := filepath.Abs(hostPath)\n    if err != nil { return err }\n    hostPath = abs\n}","typeGuard":null,"tryCatchPattern":"path, err := ts.TranslateHostPath(p)\nif err != nil && strings.Contains(err.Error(), \"relative path\") {\n    abs, aerr := filepath.Abs(p)\n    if aerr != nil { return aerr }\n    path, err = ts.TranslateHostPath(abs)\n}","preventionTips":["Always normalize with filepath.Abs before tool calls","Expand \"~\" with os.UserHomeDir — IsAbs(\"~/x\") is false","Use filepath.IsAbs as a pre-check in wrappers around the tools"],"tags":["mcp","path","validation","go"],"backgroundTag":"relative-path-not-allowed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}