Tencent/WeKnora · error

条目不能为空

Error message

条目不能为空

What it means

Basic FAQ import validation (validateFAQEntryPayloadBasic): the entries slice element being validated is a nil *FAQEntryPayload. It fires during append/replace-mode import validation when the payload contains a null entry where a FAQ object is required, before any field checks run.

Source

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

		if s != "" && !seen[s] {
			seen[s] = true
			result = append(result, s)
		}
	}
	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("答案不能全为空")
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Remove null elements from the entries array before submitting
  2. Validate the JSON payload shape at the API layer before import
  3. The failed entry is reported per-row in dry-run/import results
Defensive patterns

Strategy: validation

When it happens

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