{"record":{"id":"fd4dea280da66b88","repo":"Tencent/WeKnora","slug":"failed-to-check-oss-bucket-w","errorCode":null,"errorMessage":"failed to check OSS bucket: %w","messagePattern":"failed to check OSS bucket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/oss.go","lineNumber":55,"sourceCode":"\tif err := utils.ValidateURLForSSRF(endpoint); err != nil {\n\t\treturn nil, fmt.Errorf(\"unsafe OSS endpoint: %w\", err)\n\t}\n\tcreds := credentials.NewStaticCredentialsProvider(accessKey, secretKey, \"\")\n\n\tcfg := oss.LoadDefaultConfig().\n\t\tWithCredentialsProvider(creds).\n\t\tWithRegion(region).\n\t\tWithEndpoint(endpoint).\n\t\tWithHttpClient(utils.NewSSRFSafeHTTPClient(utils.DefaultSSRFSafeHTTPClientConfig()))\n\n\treturn oss.NewClient(cfg), nil\n}\n\n// 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","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/oss.go#L37-L73","documentation":"OSS bucket bootstrap: IsBucketExist errored while checking the configured bucket (credentials, endpoint, or network failure), so bucket existence cannot be determined and ensure/create cannot proceed.","triggerScenarios":"Thrown at internal/application/service/file/oss.go:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify OSS endpoint, region, and credentials","Check network egress to the OSS endpoint","Retry the existence check on transient errors"],"exampleFix":null,"handlingStrategy":"retry","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"}