{"record":{"id":"716de00bc4f26448","repo":"googleapis/mcp-toolbox","slug":"destination-dir-is-invalid-for-tool-q-w","errorCode":null,"errorMessage":"destination_dir is invalid for tool %q: %w","messagePattern":"destination_dir is invalid for tool %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go","lineNumber":86,"sourceCode":"var _ tools.ToolConfig = Config{}\n\nfunc (cfg Config) ToolConfigType() string {\n\treturn resourceType\n}\n\nfunc (cfg Config) Initialize(context.Context) (tools.Tool, error) {\n\tif cfg.Description == \"\" {\n\t\treturn nil, fmt.Errorf(\"description is required for tool %q\", cfg.Name)\n\t}\n\tif cfg.Bucket != nil && *cfg.Bucket == \"\" {\n\t\treturn nil, fmt.Errorf(\"bucket cannot be empty for tool %q\", cfg.Name)\n\t}\n\tif cfg.DestinationDir != nil {\n\t\tif *cfg.DestinationDir == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"destination_dir cannot be empty for tool %q\", cfg.Name)\n\t\t}\n\t\tif _, err := cloudstoragecommon.ValidateLocalPath(*cfg.DestinationDir); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"destination_dir is invalid for tool %q: %w\", cfg.Name, err)\n\t\t}\n\t}\n\n\tobjectParam := parameters.NewStringParameter(objectKey, \"Full object name (path) within the bucket, e.g. 'path/to/file.txt'.\")\n\tdestinationDesc := \"Absolute local filesystem path where the object will be written. Relative paths and paths containing '..' are rejected.\"\n\tif cfg.DestinationDir != nil {\n\t\tdestinationDesc = \"Relative path under the configured destination_dir where the object will be written. Absolute paths and paths that escape destination_dir are rejected.\"\n\t}\n\tallParameters := parameters.Parameters{}\n\tif cfg.Bucket == nil {\n\t\tallParameters = append(allParameters, parameters.NewStringParameter(bucketKey, \"Name of the Cloud Storage bucket containing the object.\"))\n\t}\n\tallParameters = append(allParameters, objectParam)\n\tallParameters = append(allParameters, parameters.NewStringParameter(destinationKey, destinationDesc))\n\tif cfg.Overwrite == nil {\n\t\tallParameters = append(allParameters, parameters.NewBooleanParameter(overwriteKey, \"If true, overwrite the destination when it already exists. If false (default), the tool returns an error when the destination exists.\", parameters.WithBooleanDefault(false)))\n\t}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go#L68-L104","documentation":"The configured destination_dir failed cloudstoragecommon.ValidateLocalPath, which requires an absolute local path and rejects paths containing '..'. The underlying validation error is wrapped with %w and surfaced in this message.","triggerScenarios":"destination_dir is relative (e.g. 'downloads' or './out') or contains a '..' traversal component (e.g. '/data/../etc') when initializing cloudstorage-download-object.","commonSituations":"Users entering relative paths in configs; attempting path traversal to write outside the sandbox; containers where the intended mount path differs from the configured one.","solutions":["Use an absolute path without '..' for destination_dir","Resolve the base directory at config time (e.g. use an absolute mounted volume path)","Run cloudstoragecommon.ValidateLocalPath on your value before deploying to see the wrapped cause"],"exampleFix":"// before\ndestination_dir: ./downloads\n// after\ndestination_dir: /var/lib/toolbox/downloads","handlingStrategy":"validation","validationCode":"if _, err := cloudstoragecommon.ValidateLocalPath(dest); err != nil {\n    return fmt.Errorf(\"invalid destination_dir: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := startToolbox(); err != nil {\n    var pathErr *fmt.wrapError\n    if errors.As(err, &pathErr) && strings.Contains(err.Error(), \"destination_dir is invalid\") {\n        // use absolute path without '..'\n    }\n    log.Fatal(err)\n}","preventionTips":["Always use absolute paths","Never include '..' segments in configured paths","Pre-validate paths with ValidateLocalPath before deploying"],"tags":["go","mcp-toolbox","configuration","path-validation"],"backgroundTag":"invalid-path","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"}