{"record":{"id":"c8a93418b31bad6d","repo":"AlistGo/alist","slug":"create-oss-bucket-failed-w","errorCode":null,"errorMessage":"create oss bucket failed: %w","messagePattern":"create oss bucket failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/guangyapan/driver.go","lineNumber":417,"sourceCode":"\tif code == 156 {\n\t\tif taskID == \"\" {\n\t\t\treturn errors.New(\"instant upload returns empty task id\")\n\t\t}\n\t\treturn d.waitUploadTaskInfo(ctx, taskID)\n\t}\n\n\tif token.ObjectPath == \"\" || token.BucketName == \"\" || token.EndPoint == \"\" || token.AccessKeyID == \"\" || token.SecretAccessKey == \"\" {\n\t\treturn errors.New(\"upload token is incomplete\")\n\t}\n\n\tossEndpoint := normalizeOSSEndpoint(token.EndPoint, token.BucketName)\n\tclient, err := oss.New(ossEndpoint, token.AccessKeyID, token.SecretAccessKey, oss.SecurityToken(token.SessionToken))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create oss client failed: %w\", err)\n\t}\n\tbucket, err := client.Bucket(token.BucketName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create oss bucket failed: %w\", err)\n\t}\n\n\tif file.GetSize() == 0 {\n\t\tif err := bucket.PutObject(token.ObjectPath, strings.NewReader(\"\")); err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tif err := d.multipartUploadToOSS(ctx, bucket, token.ObjectPath, file, up); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tif taskID == \"\" {\n\t\treturn nil\n\t}\n\treturn d.waitUploadTaskInfo(ctx, taskID)\n}\n","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/guangyapan/driver.go#L399-L435","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log token.BucketName and the wrapped error; verify it matches ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$.","Confirm DNS/TLS connectivity to the normalized endpoint from the host (curl https://<bucket>.<endpoint>).","If the bucket name is genuinely invalid, have getUploadToken map the correct field from the provider response."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var ossBucketRe = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`)\nif !ossBucketRe.MatchString(token.BucketName) {\n    return fmt.Errorf(\"upload token bucket name invalid: %q\", token.BucketName)\n}","typeGuard":null,"tryCatchPattern":"if err := bucketOp(); err != nil {\n    if strings.Contains(err.Error(), \"create oss bucket failed\") {\n        // bucket handle problem, not a data problem; check bucket name/endpoint\n    }\n}","preventionTips":["Check the OSS bucket-name regex before calling client.Bucket.","Verify network egress to the OSS endpoint when deploying in restricted environments."],"tags":["oss","upload","bucket-name","validation","guangyapan"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}