googleapis/mcp-toolbox · error
source_bucket cannot be empty for tool %q
Error message
source_bucket cannot be empty for tool %q
What it means
In cloud-storage-copyobject's Config.Initialize, source_bucket is an optional *string parameter. If it is provided (non-nil) but is the empty string, the config is invalid: the tool would render a parameter with a meaningless default. Initialize rejects it early with this error naming the tool.
Source
Thrown at internal/tools/cloudstorage/cloudstoragecopyobject/cloudstoragecopyobject.go:77
Type string `yaml:"type" validate:"required"`
Source string `yaml:"source" validate:"required"`
Annotations *tools.ToolAnnotations `yaml:"annotations,omitempty"`
SourceBucket *string `yaml:"source_bucket,omitempty"`
DestinationBucket *string `yaml:"destination_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.SourceBucket != nil && *cfg.SourceBucket == "" {
return nil, fmt.Errorf("source_bucket cannot be empty for tool %q", cfg.Name)
}
if cfg.DestinationBucket != nil && *cfg.DestinationBucket == "" {
return nil, fmt.Errorf("destination_bucket cannot be empty for tool %q", cfg.Name)
}
sourceObjectParam := parameters.NewStringParameter(sourceObjectKey, "Full source object name (path) within the source bucket, e.g. 'path/to/file.txt'.")
destinationObjectParam := parameters.NewStringParameter(destinationObjectKey, "Full destination object name (path) within the destination bucket, e.g. 'path/to/file.txt'.")
allParameters := parameters.Parameters{}
if cfg.SourceBucket == nil {
allParameters = append(allParameters, parameters.NewStringParameter(sourceBucketKey, "Name of the Cloud Storage bucket containing the source object."))
}
allParameters = append(allParameters, sourceObjectParam)
if cfg.DestinationBucket == nil {
allParameters = append(allParameters, parameters.NewStringParameter(destinationBucketKey, "Name of the Cloud Storage bucket to copy into."))
}
allParameters = append(allParameters, destinationObjectParam)
return Tool{View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set a real bucket name for source_bucket in the config, or remove the key entirely to make it a runtime parameter
- Fix the unset environment variable that templated to an empty string
- Add CI validation that rendered configs contain non-empty bucket names
Example fix
// before (tools.yaml)
sourceBucket: ${SOURCE_BUCKET} # env unset -> ""
// after
sourceBucket: my-source-bucket # or omit key to prompt at invocation Defensive patterns
Strategy: validation
Validate before calling
func checkSourceBucket(name string, ptr *string) error {
if ptr != nil && *ptr == "" {
return fmt.Errorf("tool %s: source_bucket set but empty (check env var)", name)
}
return nil
} Type guard
func hasNonEmptyBucket(p *string) bool { return p == nil || *p != "" } Try / catch
tool, err := cfg.Initialize(ctx)
if err != nil && strings.Contains(err.Error(), "source_bucket cannot be empty") {
return fmt.Errorf("set SOURCE_BUCKET env or remove the key: %w", err)
} Prevention
- Verify env vars used in config templates are set before server start
- Omit optional bucket keys instead of writing empty values
- Use ${VAR:?} style templating that fails on unset vars
- Add a startup smoke test that loads all tool configs
When it happens
Trigger: Setting `sourceBucket: ""` or `source_bucket: ""` in the tool config, or binding the pointer to an empty env-substituted value (e.g. ${SOURCE_BUCKET} unset and template resolved to empty).
Common situations: Environment variable for the bucket name not set at deploy time so the config template substitutes an empty string; YAML key present with no value (`source_bucket:`) which unmarshals to an empty string pointer.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- description is required for tool %q
- destination_bucket cannot be empty for tool %q
- description is required for tool %q
- description is required for tool %q
- doc %d: unexpected non-string key in input: %v
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/140c76eb41ad8162.
Report an issue: GitHub.