googleapis/mcp-toolbox · error
bucket cannot be empty for tool %q
Error message
bucket cannot be empty for tool %q
What it means
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("")`.
Source
Thrown at internal/tools/cloudstorage/cloudstoragegetbucketiampolicy/cloudstoragegetbucketiampolicy.go:71
tools.ConfigBase `yaml:",inline"`
Type string `yaml:"type" validate:"required"`
Source string `yaml:"source" validate:"required"`
Annotations *tools.ToolAnnotations `yaml:"annotations,omitempty"`
Bucket *string `yaml:"bucket,omitempty"`
}
var _ tools.ToolConfig = Config{}
func (cfg Config) ToolConfigType() string {
return resourceType
}
func (cfg Config) Initialize(context.Context) (tools.Tool, error) {
if cfg.Description == "" {
return nil, fmt.Errorf("description is required for tool %q", cfg.Name)
}
if cfg.Bucket != nil && *cfg.Bucket == "" {
return nil, fmt.Errorf("bucket cannot be empty for tool %q", cfg.Name)
}
allParameters := parameters.Parameters{}
if cfg.Bucket == nil {
allParameters = append(allParameters, parameters.NewStringParameter(bucketKey, "Name of the Cloud Storage bucket whose IAM policy should be returned."))
}
return Tool{
BaseTool: tools.NewBaseTool(
cfg,
tools.GetAnnotationsOrDefault(cfg.Annotations, tools.NewReadOnlyAnnotations),
tools.Manifest{Description: cfg.Description, Parameters: allParameters.Manifest(), AuthRequired: cfg.AuthRequired},
allParameters,
),
}, nil
}
var _ tools.Tool = Tool{}View on GitHub (pinned to 8cc6e09de2)
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.
Example fix
# before bucket: "" description: Get IAM policy # after bucket: my-gcs-bucket description: Get IAM policy
Defensive patterns
Strategy: validation
Validate before calling
if cfg.Bucket != nil && *cfg.Bucket == "" {
return fmt.Errorf("bucket cannot be empty for tool %q; set a name or omit the field", cfg.Name)
} Type guard
func hasBucket(cfg Config) bool { return cfg.Bucket != nil && *cfg.Bucket != "" } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- bucket cannot be empty for tool %q
- bucket cannot be empty for tool %q
- invalid source for %q tool: source %q is not a compatible ty
- description is required for tool %q
- description is required for tool %q
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/d18fe0cd7db222ad.
Report an issue: GitHub.