juicedata/juicefs · error

create bucket %s: %s

Error message

create bucket %s: %s

What it means

Returned by newB2 when the referenced bucket cannot be found and creating it (as private) also fails. Access warnings precede it; the wrapped error explains why bucket creation was rejected (credentials without create permission, or invalid name).

Source

Thrown at pkg/object/b2.go:183

	hostParts := strings.Split(uri.Host, ".")
	name := hostParts[0]
	// TODO: set UserAgent once kothar/go-backblaze supports http.Client injection
	client, err := backblaze.NewB2(backblaze.Credentials{
		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

  1. Check the bucket name is valid per B2 rules (4-63 chars, lowercase letters/digits/hyphens).
  2. Create the bucket manually via 'b2 create-bucket' or the web console, then retry.
  3. Ensure the application key has write capability and is not bucket-restricted to another bucket.
  4. Pick a different (globally unique) bucket name if it is taken.

Example fix

// before
bucket name: "Ab"   (invalid/short, creation fails)
// after
bucket name: "my-juicefs-bucket-01"
Defensive patterns

Strategy: validation

Validate before calling

var bucketNameRE = regexp.MustCompile(`^[a-z0-9-]{4,63}$`)
if !bucketNameRE.MatchString(name) { return fmt.Errorf("invalid B2 bucket name %q", name) }

Try / catch

bucket, err := client.CreateBucket(name, "allPrivate")
if err != nil {
    return fmt.Errorf("cannot create bucket %s (taken, invalid name, or key lacks write caps): %w", name, err)
}

Prevention

When it happens

Trigger: newB2 where the bucket does not exist under the authorized account and creation fails — name already taken by another account, name violates B2 bucket naming rules, or the key lacks write capability.

Common situations: Application key restricted to a different bucket; desired bucket name already registered globally in B2; invalid bucket name (length/case/characters); key without writeFiles/writeBuckets capability.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/d900598454c0b26f. Report an issue: GitHub.