AlistGo/alist · error

create oss bucket failed: %w

Error message

create oss bucket failed: %w

What it means

Thrown when client.Bucket(token.BucketName) fails after the OSS client was constructed successfully. In the aliyun OSS SDK this call validates the bucket name (lowercase letters, digits, hyphens, 3-63 chars) and the client connection settings; a network probe to the endpoint can also fail here. The %w preserves the SDK reason.

Source

Thrown at drivers/guangyapan/driver.go:417

	if code == 156 {
		if taskID == "" {
			return errors.New("instant upload returns empty task id")
		}
		return d.waitUploadTaskInfo(ctx, taskID)
	}

	if token.ObjectPath == "" || token.BucketName == "" || token.EndPoint == "" || token.AccessKeyID == "" || token.SecretAccessKey == "" {
		return errors.New("upload token is incomplete")
	}

	ossEndpoint := normalizeOSSEndpoint(token.EndPoint, token.BucketName)
	client, err := oss.New(ossEndpoint, token.AccessKeyID, token.SecretAccessKey, oss.SecurityToken(token.SessionToken))
	if err != nil {
		return fmt.Errorf("create oss client failed: %w", err)
	}
	bucket, err := client.Bucket(token.BucketName)
	if err != nil {
		return fmt.Errorf("create oss bucket failed: %w", err)
	}

	if file.GetSize() == 0 {
		if err := bucket.PutObject(token.ObjectPath, strings.NewReader("")); err != nil {
			return err
		}
	} else {
		if err := d.multipartUploadToOSS(ctx, bucket, token.ObjectPath, file, up); err != nil {
			return err
		}
	}

	if taskID == "" {
		return nil
	}
	return d.waitUploadTaskInfo(ctx, taskID)
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Log token.BucketName and the wrapped error; verify it matches ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$.
  2. Confirm DNS/TLS connectivity to the normalized endpoint from the host (curl https://<bucket>.<endpoint>).
  3. If the bucket name is genuinely invalid, have getUploadToken map the correct field from the provider response.
Defensive patterns

Strategy: validation

Validate before calling

var ossBucketRe = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`)
if !ossBucketRe.MatchString(token.BucketName) {
    return fmt.Errorf("upload token bucket name invalid: %q", token.BucketName)
}

Try / catch

if err := bucketOp(); err != nil {
    if strings.Contains(err.Error(), "create oss bucket failed") {
        // bucket handle problem, not a data problem; check bucket name/endpoint
    }
}

Prevention

When it happens

Trigger: Put() with a syntactically valid token whose BucketName violates OSS naming rules (uppercase, underscore, too short/long, or prefixed/trailing hyphen), or Bucket() failing to reach/validate the endpoint when it builds the bucket handle.

Common situations: Provider returns an internal or vanity bucket name that is not a legal OSS bucket name; token response schema shifted so BucketName gets a value from the wrong field; environment blocks outbound DNS/TLS to the OSS endpoint.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/c8a93418b31bad6d. Report an issue: GitHub.