{"record":{"id":"71683d3a7d1df171","repo":"googleapis/mcp-toolbox","slug":"bucket-cannot-be-empty-for-tool-q","errorCode":null,"errorMessage":"bucket cannot be empty for tool %q","messagePattern":"bucket cannot be empty for tool %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/cloudstorage/cloudstoragedeleteobject/cloudstoragedeleteobject.go","lineNumber":74,"sourceCode":"\ttools.ConfigBase `yaml:\",inline\"`\n\tType             string                 `yaml:\"type\" validate:\"required\"`\n\tSource           string                 `yaml:\"source\" validate:\"required\"`\n\tAnnotations      *tools.ToolAnnotations `yaml:\"annotations,omitempty\"`\n\tBucket           *string                `yaml:\"bucket,omitempty\"`\n}\n\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\n\tobjectParam := parameters.NewStringParameter(objectKey, \"Full object name (path) within the bucket, e.g. 'path/to/file.txt'.\")\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 to delete.\"))\n\t}\n\tallParameters = append(allParameters, objectParam)\n\n\treturn Tool{\n\t\tBaseTool: tools.NewBaseTool(\n\t\t\tcfg,\n\t\t\ttools.GetAnnotationsOrDefault(cfg.Annotations, tools.NewDestructiveAnnotations),\n\t\t\ttools.Manifest{Description: cfg.Description, Parameters: allParameters.Manifest(), AuthRequired: cfg.AuthRequired},\n\t\t\tallParameters,\n\t\t),\n\t}, nil\n}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragedeleteobject/cloudstoragedeleteobject.go#L56-L92","documentation":"Initialize for cloudstorage-delete-object rejects a bucket field that is explicitly provided but set to an empty string. A static bucket must be a non-empty bucket name; if you want the bucket supplied at invocation time, omit the field entirely so a bucket parameter is added.","triggerScenarios":"tools.yaml contains bucket: \"\" (e.g. an environment-variable interpolation like ${BUCKET_NAME} that expanded to empty) for a cloudstorage-delete-object tool.","commonSituations":"Env var not set at startup so ${BUCKET_NAME} renders empty; hand-edited YAML leaving bucket: with no value; templating tools stripping values.","solutions":["Set a real bucket name for the bucket field","If the bucket should come from the LLM/caller at runtime, remove the bucket field entirely (a bucket parameter is then added automatically)","Verify the environment variable used in the YAML is exported in the server process"],"exampleFix":"// before\ntools:\n  delete-object:\n    kind: cloudstorage-delete-object\n    source: my-gcs\n    description: Delete object\n    bucket: \"\"\n// after\ntools:\n  delete-object:\n    kind: cloudstorage-delete-object\n    source: my-gcs\n    description: Delete object\n    bucket: my-bucket-name","handlingStrategy":"validation","validationCode":"if bucket, ok := toolCfg[\"bucket\"]; ok && bucket == \"\" {\n    return errors.New(\"bucket must be non-empty or omitted\")\n}","typeGuard":null,"tryCatchPattern":"if err := startToolbox(); err != nil {\n    if strings.Contains(err.Error(), \"bucket cannot be empty\") {\n        // check env expansion / YAML value\n    }\n    log.Fatal(err)\n}","preventionTips":["Verify env vars used in tools.yaml are set before server start","Omit bucket entirely when it should be a runtime parameter","Validate config in CI"],"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"}