Tencent/WeKnora · error

标准问不能为空

Error message

标准问不能为空

What it means

Basic FAQ import validation (validateFAQEntryPayloadBasic): the entry's StandardQuestion, after trimming whitespace, is empty. The standard question is the mandatory canonical form of a FAQ entry, so an import row without it is rejected during append/replace-mode validation.

Source

Thrown at internal/application/service/knowledge_faq_import.go:966

	}
	for _, s := range b {
		s = strings.TrimSpace(s)
		if s != "" && !seen[s] {
			seen[s] = true
			result = append(result, s)
		}
	}
	return result
}

// validateFAQEntryPayloadBasic 验证 FAQ 条目的基本格式
func validateFAQEntryPayloadBasic(entry *types.FAQEntryPayload) error {
	if entry == nil {
		return fmt.Errorf("条目不能为空")
	}
	standardQ := strings.TrimSpace(entry.StandardQuestion)
	if standardQ == "" {
		return fmt.Errorf("标准问不能为空")
	}
	if len(entry.Answers) == 0 {
		return fmt.Errorf("答案不能为空")
	}
	hasValidAnswer := false
	for _, a := range entry.Answers {
		if strings.TrimSpace(a) != "" {
			hasValidAnswer = true
			break
		}
	}
	if !hasValidAnswer {
		return fmt.Errorf("答案不能全为空")
	}
	return nil
}

type faqMergeOperation struct {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Provide a non-blank standard question for the failing entry
  2. Trim whitespace when constructing entries client-side
  3. Use dry-run mode to list all rows missing a standard question
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/application/service/knowledge_faq_import.go:966 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/c145218ddc52b6fa. Report an issue: GitHub.