{"record":{"id":"4674c5a6906080a2","repo":"googleapis/mcp-toolbox","slug":"bucket-cannot-be-empty-for-tool-q-4674c5","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/cloudstoragegetobjectmetadata/cloudstoragegetobjectmetadata.go","lineNumber":76,"sourceCode":"\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\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\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.\"))\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.NewReadOnlyAnnotations),\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":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragegetobjectmetadata/cloudstoragegetobjectmetadata.go#L58-L94","documentation":"cloudstorage-get-object-metadata's Initialize rejects a bucket field that is a non-nil pointer to an empty string. Provide a real bucket name or omit the field entirely so bucket becomes a required parameter on the tool.","triggerScenarios":"cfg.Bucket != nil and *cfg.Bucket == \"\" during Initialize — e.g. `bucket: \"\"` in YAML or tools.Ptr(\"\") in Go.","commonSituations":"Empty string from env-var interpolation; YAML key left with no value; build-time templating leaving placeholders unresolved.","solutions":["Set `bucket: <real-bucket-name>` in the config.","Omit the `bucket` key to make it a per-invocation parameter.","Add config linting to reject empty string values for resource-name fields."],"exampleFix":"# before\nbucket: \"\"\n# after\nbucket: my-gcs-bucket","handlingStrategy":"validation","validationCode":"if cfg.Bucket != nil && strings.TrimSpace(*cfg.Bucket) == \"\" {\n    return errors.New(\"bucket cannot be empty; set a name or omit the field\")\n}","typeGuard":"func bucketSet(cfg Config) bool { return cfg.Bucket != nil && *cfg.Bucket != \"\" }","tryCatchPattern":null,"preventionTips":["Never emit `bucket: \"\"` from generators; omit the key instead","Verify env expansion produced non-empty values","Add Initialize round-trip tests for each tool config"],"tags":["go","cloudstorage","config-validation","tool-initialization"],"backgroundTag":"tool-config-validation","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"}