{"record":{"id":"b6e5d188c0954d21","repo":"googleapis/mcp-toolbox","slug":"destination-dir-cannot-be-empty-for-tool-q","errorCode":null,"errorMessage":"destination_dir cannot be empty for tool %q","messagePattern":"destination_dir cannot be empty for tool %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go","lineNumber":83,"sourceCode":"}\n\n// validate interface\nvar _ 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 {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragedownloadobject/cloudstoragedownloadobject.go#L65-L101","documentation":"Configuration-time validation in Initialize: destination_dir is present in the tool YAML but set to an empty string, which would resolve object downloads to no directory.","triggerScenarios":"destination_dir: \"\" or destination_dir pointing at an empty env var (e.g. ${DOWNLOAD_DIR} unset) in the tool config.","commonSituations":"Unset environment variable in the deployment; YAML key left blank; automated config generation emitting empty strings.","solutions":["Set destination_dir to a valid absolute local path","Remove destination_dir to expose it as a per-call parameter","Verify the env var used is set in the server process"],"exampleFix":"// before\ndestination_dir: \"\"\n// after\ndestination_dir: /data/downloads","handlingStrategy":"validation","validationCode":"if d, ok := toolCfg[\"destination_dir\"]; ok && d == \"\" {\n    return errors.New(\"destination_dir must be non-empty or omitted\")\n}","typeGuard":null,"tryCatchPattern":"if err := startToolbox(); err != nil {\n    if strings.Contains(err.Error(), \"destination_dir cannot be empty\") {\n        // set a valid absolute path or drop the key\n    }\n    log.Fatal(err)\n}","preventionTips":["Set destination_dir to a mounted absolute path in containers","Avoid blank YAML keys","Confirm env var expansion in the deployment environment"],"tags":["go","mcp-toolbox","configuration","validation"],"backgroundTag":"empty-required-parameter","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"}