{"record":{"id":"62210abcf1795a28","repo":"googleapis/mcp-toolbox","slug":"bucket-cannot-be-empty-for-tool-q-62210a","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/cloudstoragereadobject/cloudstoragereadobject.go","lineNumber":78,"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\trangeParam := parameters.NewStringParameter(rangeKey, \"Optional HTTP byte range, e.g. 'bytes=0-999' (first 1000 bytes), 'bytes=-500' (last 500 bytes), or 'bytes=500-' (from byte 500 to end). Empty reads the full object.\", parameters.WithStringDefault(\"\"))\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, rangeParam)\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","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/cloudstorage/cloudstoragereadobject/cloudstoragereadobject.go#L60-L96","documentation":"Thrown by cloudstorage-read-object Config.Initialize when the optional 'bucket' field is supplied as an empty string. When bucket is configured it must be a real GCS bucket name; otherwise remove the field so the bucket is provided per invocation.","triggerScenarios":"tools.yaml contains `bucket: \"\"` or an empty env-expanded value for a cloudstorage-read-object tool.","commonSituations":"Unset BUCKET environment variable interpolated to empty; leaving an empty quoted value instead of deleting the line; copy/paste of config skeletons.","solutions":["Remove the empty 'bucket' field from the tool config","Set a valid bucket name (e.g. `bucket: my-bucket`)","Correct the environment variable so it resolves to a non-empty bucket name"],"exampleFix":"// before\n  read-object:\n    kind: cloudstorage-read-object\n    source: my-gcs\n    description: Read object\n    bucket: \"\"\n// after\n  read-object:\n    kind: cloudstorage-read-object\n    source: my-gcs\n    description: Read object\n    bucket: my-bucket","handlingStrategy":"validation","validationCode":"if b, exists := cfg[\"bucket\"]; exists && (b == \"\" || b == nil) {\n    return errors.New(\"bucket must be a non-empty name or removed entirely\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not quote empty values for optional fields; delete them instead","Verify env substitutions in config-rendering logs","Fail fast on empty interpolated values during templating"],"tags":["go","configuration","cloud-storage","validation"],"backgroundTag":"missing-required-config-field","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"}