{"record":{"id":"48fe73547b16defe","repo":"Tencent/WeKnora","slug":"failed-to-save-csv-file-w","errorCode":null,"errorMessage":"failed to save CSV file: %w","messagePattern":"failed to save CSV file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq_import.go","lineNumber":286,"sourceCode":"\t\t}\n\t\tanswerAll := \"false\"\n\t\tif entry.AnswerAll {\n\t\t\tanswerAll = \"true\"\n\t\t}\n\t\tisDisabled := \"false\"\n\t\tif entry.IsDisabled {\n\t\t\tisDisabled = \"true\"\n\t\t}\n\n\t\tbuf.WriteString(fmt.Sprintf(\"%s,%s,%s,%s,%s,%s,%s,%s\\n\",\n\t\t\treason, tagName, standardQ, similarQs, negativeQs, answers, answerAll, isDisabled))\n\t}\n\n\t// 上传 CSV 文件到临时存储（会自动过期）\n\tfileName := fmt.Sprintf(\"faq_dryrun_failed_%s.csv\", taskID)\n\tfilePath, err := s.fileSvc.SaveBytes(ctx, []byte(buf.String()), tenantID, fileName, true)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to save CSV file: %w\", err)\n\t}\n\n\t// 获取下载 URL\n\tfileURL, err := s.fileSvc.GetFileURL(ctx, filePath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get file URL: %w\", err)\n\t}\n\n\tlogger.Infof(ctx, \"Generated failed entries CSV: %s, entries: %d\", fileURL, len(failedEntries))\n\treturn fileURL, nil\n}\n\n// csvEscape 转义 CSV 字段\nfunc csvEscape(s string) string {\n\tif strings.ContainsAny(s, \",\\\"\\n\\r\") {\n\t\t// 将内部引号替换为两个引号，并用引号包裹整个字段\n\t\treturn \"\\\"\" + strings.ReplaceAll(s, \"\\\"\", \"\\\"\\\"\") + \"\\\"\"\n\t}","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq_import.go#L268-L304","documentation":"Thrown inside generateFailedEntriesCSV when fileSvc.SaveBytes fails to upload the CSV of failed FAQ dry-run entries to temporary (auto-expiring) storage. A storage-layer failure; the caller cannot produce a download link for failed rows.","triggerScenarios":"Thrown at internal/application/service/knowledge_faq_import.go:286 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check object storage availability and tenant credentials","Confirm temp-bucket write permissions and expiry policy","Retry the dry run; failed-entry rows also remain in the progress record"],"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"}