juicedata/juicefs · error
can't find bucket %s with provided Key ID
Error message
can't find bucket %s with provided Key ID
What it means
Thrown when the B2 client could neither fetch nor create the bucket: Bucket(name) returned nil (no error) and the code cannot proceed without a bucket handle. The named bucket does not exist under the credentials provided.
Source
Thrown at pkg/object/b2.go:187
KeyID: keyID,
ApplicationKey: applicationKey,
})
if err != nil {
return nil, fmt.Errorf("create B2 client: %s", err)
}
client.MaxIdleUploads = 20
bucket, err := client.Bucket(name)
if err != nil {
logger.Warnf("access bucket %s: %s", name, err)
}
if err == nil && bucket == nil {
bucket, err = client.CreateBucket(name, "allPrivate")
if err != nil {
return nil, fmt.Errorf("create bucket %s: %s", name, err)
}
}
if bucket == nil {
return nil, fmt.Errorf("can't find bucket %s with provided Key ID", name)
}
return &b2client{bucket: bucket}, nil
}
func init() {
Register("b2", newB2)
}
View on GitHub (pinned to c9a67b23e8)
Solutions
- Verify the bucket name exactly (B2 names are case-sensitive and must match).
- Confirm the application key is authorized for that bucket (allInKey or the specific bucket).
- Check the bucket exists with 'b2 list-buckets'.
- Use a master key or generate a key scoped to the correct bucket.
Example fix
// before key scoped to bucket "old-bucket", endpoint references "new-bucket" -> not found // after generate a key restricted to "new-bucket" (or use the account master key) and retry
Defensive patterns
Strategy: validation
Validate before calling
buckets, _, err := client.ListBuckets()
if err != nil { return err }
found := false
for _, b := range buckets { if b.BucketName == name { found = true } }
if !found { return fmt.Errorf("bucket %q not visible to this key", name) } Try / catch
bucket, err := client.Bucket(name)
if err != nil { return fmt.Errorf("lookup failed: %w", err) }
if bucket == nil { return fmt.Errorf("bucket %q not found or not authorized for this key", name) } Prevention
- List buckets with 'b2 list-buckets' to confirm visibility before mount
- Scope application keys to the exact bucket they will use
- Keep bucket names in a single source of truth to avoid typos
When it happens
Trigger: newB2 where client.Bucket(name) returns nil,nil (bucket not visible to this key) and CreateBucket is skipped or not attempted because err != nil from the earlier lookup, leaving bucket nil.
Common situations: Bucket name typo; application key restricted to a different bucket (unauthorized buckets are invisible); bucket deleted before mount; bucket lives under a different account than the key.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- create bucket %s: %s
- Failed to put: %s
- expect mode %o but got %o
- Invalid endpoint: %v, error: %v
- create B2 client: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/0eca7ecc4fc1108c.
Report an issue: GitHub.