{"record":{"id":"e60f1433bcae11cd","repo":"googleapis/mcp-toolbox","slug":"directory-q-is-invalid-w","errorCode":null,"errorMessage":"directory %q is invalid: %w","messagePattern":"directory %q is invalid: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudstorage/cloudstoragecommon/paths.go","lineNumber":126,"sourceCode":"\n// escapes reports whether target lies outside dir. Both are expected to be\n// cleaned absolute paths.\nfunc escapes(dir, target string) (bool, error) {\n\twithin, err := filepath.Rel(dir, target)\n\tif err != nil {\n\t\treturn true, err\n\t}\n\treturn within == \"..\" || strings.HasPrefix(within, \"..\"+string(filepath.Separator)) || filepath.IsAbs(within), nil\n}\n\n// ResolveWithinDir joins rel onto dir and returns the result only if it stays\n// inside dir, both as written and after symlinks are resolved. The returned\n// path is the cleaned join, not the symlink-resolved target, so callers keep\n// reporting the location the user asked for.\nfunc ResolveWithinDir(dir, rel string) (string, error) {\n\tcleanDir, err := ValidateLocalPath(dir)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"directory %q is invalid: %w\", dir, err)\n\t}\n\tif rel == \"\" {\n\t\treturn \"\", fmt.Errorf(\"relative path is empty\")\n\t}\n\tif filepath.IsAbs(rel) {\n\t\treturn \"\", fmt.Errorf(\"path %q must be relative\", rel)\n\t}\n\n\tcleanDest := filepath.Clean(filepath.Join(cleanDir, rel))\n\tout, err := escapes(cleanDir, cleanDest)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"path %q cannot be resolved within %q: %w\", rel, cleanDir, err)\n\t}\n\tif out {\n\t\treturn \"\", fmt.Errorf(\"path %q escapes configured directory %q\", rel, cleanDir)\n\t}\n\n\t// Repeat the check against the real targets. A symlink under cleanDir can","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragecommon/paths.go#L108-L144","documentation":"Wrap of a ValidateLocalPath failure on the configured base directory inside ResolveWithinDir: the directory passed as `dir` (typically destination_dir) is not a valid cleaned absolute local path, so containment checking cannot proceed.","triggerScenarios":"Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:126 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set destination_dir to a cleaned absolute filesystem path in the tool configuration","Ensure the directory exists and contains no symlinks or components that fail local path validation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}