{"record":{"id":"632a8bc174ee1029","repo":"Tencent/WeKnora","slug":"failed-to-set-faq-import-result-w","errorCode":null,"errorMessage":"failed to set FAQ import result: %w","messagePattern":"failed to set FAQ import result: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq_import.go","lineNumber":348,"sourceCode":"\t\tPartialFailedCount: progress.PartialFailedCount,\n\t\tSkippedCount:       skippedCount,\n\t\tMergedCount:        progress.MergedCount,\n\t\tAddedCount:         progress.AddedCount,\n\t\tImportMode:         payload.Mode,\n\t\tImportedAt:         time.Now(),\n\t\tTaskID:             payload.TaskID,\n\t\tProcessingTime:     time.Now().Unix() - progress.CreatedAt, // 处理耗时（秒）\n\t\tDisplayStatus:      \"open\",                                 // 新导入的结果默认显示\n\t}\n\n\t// 如果有失败/部分失败条目 CSV 下载 URL，则写入结果（FailedEntries 包含完全失败与部分失败）\n\tif progress.FailedEntriesURL != \"\" {\n\t\timportResult.FailedEntriesURL = progress.FailedEntriesURL\n\t}\n\n\t// 设置导入结果到Knowledge的metadata中\n\tif err := knowledge.SetLastFAQImportResult(importResult); err != nil {\n\t\treturn fmt.Errorf(\"failed to set FAQ import result: %w\", err)\n\t}\n\n\t// 更新数据库\n\tif err := s.repo.UpdateKnowledge(ctx, knowledge); err != nil {\n\t\treturn fmt.Errorf(\"failed to update knowledge with import result: %w\", err)\n\t}\n\n\tlogger.Infof(ctx, \"Saved FAQ import result to database: knowledge_id=%s, task_id=%s, total=%d, success=%d, added=%d, merged=%d, failed=%d, partial_failed=%d, skipped=%d\",\n\t\tpayload.KnowledgeID, payload.TaskID, originalTotalEntries, progress.SuccessCount, progress.AddedCount, progress.MergedCount, progress.FailedCount, progress.PartialFailedCount, skippedCount)\n\n\treturn nil\n}\n\n// buildFAQFailedEntry 构建 FAQFailedEntry\nfunc buildFAQFailedEntry(idx int, reason string, entry *types.FAQEntryPayload) types.FAQFailedEntry {\n\tanswerAll := false\n\tif entry.AnswerStrategy != nil && *entry.AnswerStrategy == types.AnswerStrategyAll {\n\t\tanswerAll = true","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq_import.go#L330-L366","documentation":"Thrown when Knowledge.SetLastFAQImportResult fails to serialize the FAQ import result (counts, timings, failed-entries URL) into the knowledge metadata before persisting. Indicates the result struct contains a value JSON encoding rejects.","triggerScenarios":"Thrown at internal/application/service/knowledge_faq_import.go:348 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error for the offending field","Keep FAQImportResult fields to JSON-safe scalar/slice types","Add a unit test serializing a fully populated import result"],"exampleFix":null,"handlingStrategy":"type-guard","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"}