{"record":{"id":"85b79f7108f03b38","repo":"Tencent/WeKnora","slug":"failed-to-create-bucket-w-85b79f","errorCode":null,"errorMessage":"failed to create bucket: %w","messagePattern":"failed to create bucket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/s3.go","lineNumber":113,"sourceCode":"// NewS3FileService creates an AWS S3 file service.\n// It verifies that the bucket exists and creates it if missing.\nfunc NewS3FileService(endpoint,\n\taccessKey, secretKey, bucketName, region, pathPrefix string,\n) (interfaces.FileService, error) {\n\tsvc, err := newS3Client(endpoint, accessKey, secretKey, bucketName, region, pathPrefix, false)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Check if bucket exists\n\texists, err := svc.bucketExists(context.Background())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to check bucket: %w\", err)\n\t}\n\n\tif !exists {\n\t\tif err = svc.createBucket(context.Background()); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create bucket: %w\", err)\n\t\t}\n\t}\n\n\treturn svc, nil\n}\n\n// NewS3FileServiceWithOptions is the instance-aware S3 constructor. Existing\n// callers keep the historical endpoint-based path-style inference.\nfunc NewS3FileServiceWithOptions(endpoint, accessKey, secretKey, bucketName, region, pathPrefix string, forcePathStyle bool) (interfaces.FileService, error) {\n\tsvc, err := newS3Client(endpoint, accessKey, secretKey, bucketName, region, pathPrefix, forcePathStyle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\texists, err := svc.bucketExists(context.Background())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to check bucket: %w\", err)\n\t}\n\tif !exists {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/s3.go#L95-L131","documentation":"S3 service constructor: the configured bucket was reported missing and createBucket failed while attempting to create it (permissions, region constraints, or name conflict), so the file service cannot initialize and construction aborts.","triggerScenarios":"Thrown at internal/application/service/file/s3.go:113 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check S3 credentials have CreateBucket permission","Pre-create the bucket with correct region settings","Inspect the wrapped AWS error for the specific 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"}