Tencent/WeKnora · error
failed to set FAQ import result: %w
Error message
failed to set FAQ import result: %w
What it means
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.
Source
Thrown at internal/application/service/knowledge_faq_import.go:348
PartialFailedCount: progress.PartialFailedCount,
SkippedCount: skippedCount,
MergedCount: progress.MergedCount,
AddedCount: progress.AddedCount,
ImportMode: payload.Mode,
ImportedAt: time.Now(),
TaskID: payload.TaskID,
ProcessingTime: time.Now().Unix() - progress.CreatedAt, // 处理耗时(秒)
DisplayStatus: "open", // 新导入的结果默认显示
}
// 如果有失败/部分失败条目 CSV 下载 URL,则写入结果(FailedEntries 包含完全失败与部分失败)
if progress.FailedEntriesURL != "" {
importResult.FailedEntriesURL = progress.FailedEntriesURL
}
// 设置导入结果到Knowledge的metadata中
if err := knowledge.SetLastFAQImportResult(importResult); err != nil {
return fmt.Errorf("failed to set FAQ import result: %w", err)
}
// 更新数据库
if err := s.repo.UpdateKnowledge(ctx, knowledge); err != nil {
return fmt.Errorf("failed to update knowledge with import result: %w", err)
}
logger.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",
payload.KnowledgeID, payload.TaskID, originalTotalEntries, progress.SuccessCount, progress.AddedCount, progress.MergedCount, progress.FailedCount, progress.PartialFailedCount, skippedCount)
return nil
}
// buildFAQFailedEntry 构建 FAQFailedEntry
func buildFAQFailedEntry(idx int, reason string, entry *types.FAQEntryPayload) types.FAQFailedEntry {
answerAll := false
if entry.AnswerStrategy != nil && *entry.AnswerStrategy == types.AnswerStrategyAll {
answerAll = trueView on GitHub (pinned to 988cbb0330)
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
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at internal/application/service/knowledge_faq_import.go:348 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/632a8bc174ee1029.
Report an issue: GitHub.