{"record":{"id":"69ec89b838716f9d","repo":"Tencent/WeKnora","slug":"failed-to-initialize-oss-temp-client-w","errorCode":null,"errorMessage":"failed to initialize OSS temp client: %w","messagePattern":"failed to initialize OSS temp client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/oss.go","lineNumber":98,"sourceCode":"// 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 {\n\t\treturn nil, err\n\t}\n\n\tvar tempClient *oss.Client\n\tif tempBucketName != \"\" {\n\t\tif tempRegion == \"\" {\n\t\t\ttempRegion = region\n\t\t}\n\t\ttempClient, err = newOSSClient(endpoint, tempRegion, accessKey, secretKey)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to initialize OSS temp client: %w\", err)\n\t\t}\n\t\tif err := ossEnsureBucket(tempClient, tempBucketName); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\t// Normalize pathPrefix: ensure it ends with '/' if not empty\n\tif pathPrefix != \"\" && !strings.HasSuffix(pathPrefix, \"/\") {\n\t\tpathPrefix += \"/\"\n\t}\n\n\treturn &ossFileService{\n\t\tclient:         client,\n\t\ttempClient:     tempClient,\n\t\tpathPrefix:     pathPrefix,\n\t\tbucketName:     bucketName,\n\t\ttempBucketName: tempBucketName,\n\t}, nil","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/oss.go#L80-L116","documentation":"Constructing the secondary OSS client for the temp bucket failed after the main bucket was ensured: newOSSClient for the temp region/credentials (or SSRF endpoint validation on it) errored, so temp-bucket support cannot be initialized.","triggerScenarios":"Thrown at internal/application/service/file/oss.go:98 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify temp bucket endpoint, region, and credentials","Check SSRF allowlisting for the temp endpoint","Disable temp bucket config if the feature is unused"],"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"}