{"record":{"id":"95e286fc243a1900","repo":"Tencent/WeKnora","slug":"failed-to-check-faq-question-duplicate-w","errorCode":null,"errorMessage":"failed to check FAQ question duplicate: %w","messagePattern":"failed to check FAQ question duplicate: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq.go","lineNumber":1833,"sourceCode":"\t\t// 检查反例是否与相似问重复\n\t\tif _, exists := positiveQuestions[q]; exists {\n\t\t\treturn werrors.NewBadRequestError(fmt.Sprintf(\"反例问题「%s」不能与相似问相同\", q))\n\t\t}\n\t\t// 检查反例之间是否重复\n\t\tif _, exists := negativeQuestionsSeen[q]; exists {\n\t\t\treturn werrors.NewBadRequestError(fmt.Sprintf(\"反例问题「%s」重复\", q))\n\t\t}\n\t\tnegativeQuestionsSeen[q] = struct{}{}\n\t}\n\n\t// 4. 将标准问和所有相似问合并，用一条 DB 查询检查是否与其他条目冲突（替代全量扫描）\n\tallQuestions := make([]string, 0, 1+len(meta.SimilarQuestions))\n\tallQuestions = append(allQuestions, meta.StandardQuestion)\n\tallQuestions = append(allQuestions, meta.SimilarQuestions...)\n\n\tdupChunk, err := s.chunkRepo.FindFAQChunkWithDuplicateQuestion(ctx, tenantID, kbID, excludeChunkID, allQuestions)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to check FAQ question duplicate: %w\", err)\n\t}\n\tif dupChunk == nil {\n\t\treturn nil\n\t}\n\n\texistingMeta, err := dupChunk.FAQMetadata()\n\tif err != nil || existingMeta == nil {\n\t\treturn werrors.NewBadRequestError(\"标准问或相似问与已有条目重复\")\n\t}\n\n\t// 5–7. 与原先全量扫描一致的报错语义：先检查标准问，再逐条检查相似问\n\texistingSimilarSet := make(map[string]struct{}, len(existingMeta.SimilarQuestions))\n\tfor _, q := range existingMeta.SimilarQuestions {\n\t\tif q != \"\" {\n\t\t\texistingSimilarSet[q] = struct{}{}\n\t\t}\n\t}\n","sourceCodeStart":1815,"sourceCodeEnd":1851,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq.go#L1815-L1851","documentation":"The batched duplicate-question DB check failed: FindOneQuestion (looking for an existing chunk matching any of the standard+similar questions) errored, so FAQ uniqueness cannot be verified and the create/update operation aborts rather than risking duplicate entries.","triggerScenarios":"Thrown at internal/application/service/knowledge_faq.go:1833 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped chunk-repo error for the DB cause","Check database connectivity and the question-hash index","Retry the duplicate check before failing the FAQ write"],"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"}