{"record":{"id":"0b736b52210f150b","repo":"Tencent/WeKnora","slug":"failed-to-create-oss-bucket-w","errorCode":null,"errorMessage":"failed to create OSS bucket: %w","messagePattern":"failed to create OSS bucket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/oss.go","lineNumber":69,"sourceCode":"// ossEnsureBucket checks if the bucket exists and creates it if missing.\nfunc ossEnsureBucket(client *oss.Client, bucketName string) error {\n\texists, err := client.IsBucketExist(context.Background(), bucketName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check OSS bucket: %w\", err)\n\t}\n\tif exists {\n\t\treturn nil\n\t}\n\n\t_, err = client.PutBucket(context.Background(), &oss.PutBucketRequest{\n\t\tBucket: oss.Ptr(bucketName),\n\t})\n\tif err != nil {\n\t\tvar svcErr *oss.ServiceError\n\t\tif errors.As(err, &svcErr) && svcErr.StatusCode == http.StatusConflict {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"failed to create OSS bucket: %w\", err)\n\t}\n\treturn nil\n}\n\n// NewOssFileService creates an Aliyun OSS file service.\n// It verifies that the bucket exists and creates it if missing.\nfunc NewOssFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error) {\n\treturn NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, \"\", \"\")\n}\n\n// NewOssFileServiceWithTempBucket creates an Aliyun OSS file service with optional temp bucket.\nfunc NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error) {\n\tclient, err := newOSSClient(endpoint, region, accessKey, secretKey)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif err := ossEnsureBucket(client, bucketName); err != nil {","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/oss.go#L51-L87","documentation":"OSS bucket bootstrap: the bucket was reported missing and PutBucket creation failed with a non-409 error (permissions, quota, or invalid name), so the bucket cannot be ensured and service construction aborts.","triggerScenarios":"Thrown at internal/application/service/file/oss.go:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check credentials have bucket-creation permission","Pre-create the bucket manually","Inspect the wrapped ServiceError for the exact OSS denial"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}