Tencent/WeKnora · error

failed to check FAQ question duplicate: %w

Error message

failed to check FAQ question duplicate: %w

What it means

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.

Source

Thrown at internal/application/service/knowledge_faq.go:1833

		// 检查反例是否与相似问重复
		if _, exists := positiveQuestions[q]; exists {
			return werrors.NewBadRequestError(fmt.Sprintf("反例问题「%s」不能与相似问相同", q))
		}
		// 检查反例之间是否重复
		if _, exists := negativeQuestionsSeen[q]; exists {
			return werrors.NewBadRequestError(fmt.Sprintf("反例问题「%s」重复", q))
		}
		negativeQuestionsSeen[q] = struct{}{}
	}

	// 4. 将标准问和所有相似问合并,用一条 DB 查询检查是否与其他条目冲突(替代全量扫描)
	allQuestions := make([]string, 0, 1+len(meta.SimilarQuestions))
	allQuestions = append(allQuestions, meta.StandardQuestion)
	allQuestions = append(allQuestions, meta.SimilarQuestions...)

	dupChunk, err := s.chunkRepo.FindFAQChunkWithDuplicateQuestion(ctx, tenantID, kbID, excludeChunkID, allQuestions)
	if err != nil {
		return fmt.Errorf("failed to check FAQ question duplicate: %w", err)
	}
	if dupChunk == nil {
		return nil
	}

	existingMeta, err := dupChunk.FAQMetadata()
	if err != nil || existingMeta == nil {
		return werrors.NewBadRequestError("标准问或相似问与已有条目重复")
	}

	// 5–7. 与原先全量扫描一致的报错语义:先检查标准问,再逐条检查相似问
	existingSimilarSet := make(map[string]struct{}, len(existingMeta.SimilarQuestions))
	for _, q := range existingMeta.SimilarQuestions {
		if q != "" {
			existingSimilarSet[q] = struct{}{}
		}
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Inspect the wrapped chunk-repo error for the DB cause
  2. Check database connectivity and the question-hash index
  3. Retry the duplicate check before failing the FAQ write
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/knowledge_faq.go:1833 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/95e286fc243a1900. Report an issue: GitHub.