juicedata/juicefs · error

bucket %q does not exist

Error message

bucket %q does not exist

What it means

When no region is embedded in the endpoint, newOBS calls autoOBSEndpoint, which lists all buckets for the credentials and searches for one named bucketName to learn its location. If ListBuckets succeeds but no bucket with that name exists (or the credentials cannot see it), it returns 'bucket "<name>" does not exist'.

Source

Thrown at pkg/object/obs.go:381

	endpoint := fmt.Sprintf("https://obs.%s.myhuaweicloud.com", region)

	obsCli, err := obs.New(accessKey, secretKey, endpoint, obs.WithSecurityToken(token))
	if err != nil {
		return "", err
	}
	defer obsCli.Close()

	result, err := obsCli.ListBuckets(&obs.ListBucketsInput{QueryLocation: true})
	if err != nil {
		return "", err
	}
	for _, bucket := range result.Buckets {
		if bucket.Name == bucketName {
			logger.Debugf("Get location of bucket %q: %s", bucketName, bucket.Location)
			return fmt.Sprintf("obs.%s.myhuaweicloud.com", bucket.Location), nil
		}
	}
	return "", fmt.Errorf("bucket %q does not exist", bucketName)
}

func newOBS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {
	if !strings.Contains(endpoint, "://") {
		endpoint = fmt.Sprintf("https://%s", endpoint)
	}
	uri, err := url.ParseRequestURI(endpoint)
	if err != nil {
		return nil, fmt.Errorf("invalid endpoint %s: %q", endpoint, err)
	}
	hostParts := strings.SplitN(uri.Host, ".", 2)
	bucketName := hostParts[0]
	if len(hostParts) > 1 {
		endpoint = fmt.Sprintf("%s://%s", uri.Scheme, hostParts[1])
	}

	if accessKey == "" {
		accessKey = os.Getenv("HWCLOUD_ACCESS_KEY")

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Verify the bucket name spelling and that it exists in your Huawei Cloud account
  2. Check credentials (OBS_ACCESS_KEY/OBS_SECRET_KEY or env) match the bucket's owner
  3. Grant the key permission to list buckets, or specify the region explicitly in the endpoint (e.g. obs.cn-north-1.myhuaweicloud.com)
  4. Recreate the bucket if it was deleted

Example fix

// before
object.CreateStorage("obs", "mybucket", ak, sk, "")
// after
object.CreateStorage("obs", "mybucket.obs.cn-north-1.myhuaweicloud.com", ak, sk, "")
Defensive patterns

Strategy: validation

Validate before calling

// list buckets with the same credentials before use
cli, _ := obs.New(ak, sk, "https://obs.myhuaweicloud.com")
res, err := cli.ListBuckets(&obs.ListBucketsInput{})
// ensure res.Buckets contains the target name

Try / catch

if err != nil && strings.Contains(err.Error(), "does not exist") {
	// fix bucket name or credentials, or specify regional endpoint
}

Prevention

When it happens

Trigger: Creating OBS storage with a bucket-only endpoint (no obs.<region>.myhuaweicloud.com host) while the bucket is absent from the ListBuckets result for the given access/secret keys.

Common situations: Typo in bucket name; bucket belongs to another account/region and credentials lack ListBuckets permission across it; wrong credentials for that bucket; bucket deleted.

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


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