dutchcoders/transfer.sh · error
bucket not set.
Error message
bucket not set.
What it means
Thrown by the transfer.sh CLI when --provider s3 is selected and both AWS keys are present but --bucket is empty. The bucket names the S3 destination for uploaded files; without it the storage backend has no target, so the CLI refuses to start. It is the last of the three mandatory S3 flag checks before NewS3Storage is called.
Source
Thrown at cmd/cmd.go:492
}
if ipBlacklist := c.String("ip-blacklist"); ipBlacklist != "" {
applyIPFilter = true
ipFilterOptions.BlockedIPs = strings.Split(ipBlacklist, ",")
}
if applyIPFilter {
options = append(options, server.FilterOptions(ipFilterOptions))
}
switch provider := c.String("provider"); provider {
case "s3":
if accessKey := c.String("aws-access-key"); accessKey == "" {
return errors.New("access-key not set.")
} else if secretKey := c.String("aws-secret-key"); secretKey == "" {
return errors.New("secret-key not set.")
} else if bucket := c.String("bucket"); bucket == "" {
return errors.New("bucket not set.")
} else if store, err := storage.NewS3Storage(c.Context, accessKey, secretKey, bucket, purgeDays, c.String("s3-region"), c.String("s3-endpoint"), c.Bool("s3-no-multipart"), c.Bool("s3-path-style"), logger); err != nil {
return err
} else {
options = append(options, server.UseStorage(store))
}
case "gdrive":
chunkSize := c.Int("gdrive-chunk-size") * 1024 * 1024
if clientJSONFilepath := c.String("gdrive-client-json-filepath"); clientJSONFilepath == "" {
return errors.New("gdrive-client-json-filepath not set.")
} else if localConfigPath := c.String("gdrive-local-config-path"); localConfigPath == "" {
return errors.New("gdrive-local-config-path not set.")
} else if basedir := c.String("basedir"); basedir == "" {
return errors.New("basedir not set.")
} else if store, err := storage.NewGDriveStorage(c.Context, clientJSONFilepath, localConfigPath, basedir, chunkSize, logger); err != nil {
return err
} else {
options = append(options, server.UseStorage(store))View on GitHub (pinned to c37bfd9579)
Solutions
- Add --bucket <your-bucket-name> to the command line
- If per-env, generate the flag from an env var with a guard: : "${S3_BUCKET:?S3_BUCKET must be set}"
- Confirm the bucket exists and is writable by the given credentials — the next failure mode after this check is an S3 error from NewS3Storage
Example fix
// before transfer.sh --provider s3 --aws-access-key AK --aws-secret-key SK // after transfer.sh --provider s3 --aws-access-key AK --aws-secret-key SK --bucket my-uploads
Defensive patterns
Strategy: validation
Validate before calling
: "${S3_BUCKET:?bucket required for s3 provider}"
args+=(--bucket "$S3_BUCKET") Try / catch
if err := cmd.Root.Execute(); err != nil {
if strings.Contains(err.Error(), "bucket not set") {
log.Fatalf("S3 provider selected but --bucket is missing")
}
os.Exit(1)
} Prevention
- Parameterize bucket per environment and fail fast if the env var is unset
- Pre-create the bucket and verify IAM permissions after fixing the flag
- Keep a canonical s3 flag template (keys + bucket) in deployment configs
When it happens
Trigger: Running with --provider s3 and both key flags but no --bucket; also a bucket value of "" from an unset env interpolation (e.g. --bucket "$S3_BUCKET" with the variable empty).
Common situations: Multi-environment deployments where the bucket differs per env and the staging value was never set; renamed/deleted buckets whose references were removed from config; copy-pasting a minimal s3 example that only includes credentials.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- access-key not set.
- secret-key not set.
- storj-bucket not set.
- clamav-host not set
- gdrive-client-json-filepath not set.
AI-assisted analysis of dutchcoders/transfer.sh@c37bfd9579 (2026-09-05).
Data as JSON: /api/errors/549f386c63b7d01a.
Report an issue: GitHub.