{"record":{"id":"85c50db9ebb7dd88","repo":"googleapis/mcp-toolbox","slug":"relative-path-is-empty","errorCode":null,"errorMessage":"relative path is empty","messagePattern":"relative path is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudstorage/cloudstoragecommon/paths.go","lineNumber":129,"sourceCode":"func 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\n\t// point anywhere, so the name-level check above proves nothing on its own.\n\tresolvedDir, err := ResolveSymlinks(cleanDir)\n\tif err != nil {","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragecommon/paths.go#L111-L147","documentation":"Guard inside ResolveWithinDir: the relative path argument `rel` is the empty string, so there is no object path to join onto the configured directory.","triggerScenarios":"Thrown at internal/tools/cloudstorage/cloudstoragecommon/paths.go:129 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a non-empty relative object path (e.g. 'folder/object.txt')","Leave the parameter unset instead of sending an empty string"],"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"}