{"record":{"id":"d18fe0cd7db222ad","repo":"googleapis/mcp-toolbox","slug":"bucket-cannot-be-empty-for-tool-q-d18fe0","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/cloudstoragegetbucketiampolicy/cloudstoragegetbucketiampolicy.go","lineNumber":71,"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\tallParameters := parameters.Parameters{}\n\tif cfg.Bucket == nil {\n\t\tallParameters = append(allParameters, parameters.NewStringParameter(bucketKey, \"Name of the Cloud Storage bucket whose IAM policy should be returned.\"))\n\t}\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}\n\nvar _ tools.Tool = Tool{}","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragegetbucketiampolicy/cloudstoragegetbucketiampolicy.go#L53-L89","documentation":"This error is thrown by the cloudstorage-get-bucket-iam-policy tool's Config.Initialize when a bucket name was provided (the `bucket` field is non-nil) but its value is an empty string. The toolbox validates tool configs at startup so misconfigured tools fail fast instead of at invocation time. An empty pointer-deref'd bucket means the YAML config set `bucket: \"\"` or the programmatic config passed `tools.Ptr(\"\")`.","triggerScenarios":"Initializing a cloudstorage-get-bucket-iam-policy tool where cfg.Bucket != nil and *cfg.Bucket == \"\" — e.g. YAML `bucket: \"\"` or code passing an empty-string pointer as a fixed bucket.","commonSituations":"Templated configs where a placeholder was substituted with an empty value; env-var expansion producing an empty string; hand-edited YAML leaving the bucket value blank.","solutions":["Set a real bucket name in the tool config, e.g. `bucket: my-bucket`.","If the bucket should come from the model at invocation time, remove the `bucket` field entirely so it becomes a required tool parameter.","Validate config values (check for empty strings after env substitution) before calling Initialize."],"exampleFix":"# before\nbucket: \"\"\ndescription: Get IAM policy\n# after\nbucket: my-gcs-bucket\ndescription: Get IAM policy","handlingStrategy":"validation","validationCode":"if cfg.Bucket != nil && *cfg.Bucket == \"\" {\n    return fmt.Errorf(\"bucket cannot be empty for tool %q; set a name or omit the field\", cfg.Name)\n}","typeGuard":"func hasBucket(cfg Config) bool { return cfg.Bucket != nil && *cfg.Bucket != \"\" }","tryCatchPattern":null,"preventionTips":["Omit the bucket field instead of setting it to empty string when you want a runtime parameter","Lint tool YAML for empty-string resource identifiers","Check env-var substitution results before building configs"],"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"}