Tencent/WeKnora · error

failed to update knowledge

Error message

failed to update knowledge: %w

What it means

Thrown in ProcessSummaryGeneration when repo.UpdateKnowledge fails while persisting a summary-stage state transition (e.g. insufficient-content fallback state). The LLM result or fallback cannot be recorded on the knowledge record.

Solutions

  1. Check database connectivity and retry the summary task
  2. Verify the knowledge row exists and is not locked or deleted mid-processing
  3. Inspect the wrapped error for constraint violations
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/knowledge_process.go:1248 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/77302d1ea3912dfa. Report an issue: GitHub.

Appendix: source

Thrown at internal/application/service/knowledge_process.go:1248

		// Surface the underlying LLM/IO error on the span so the trace UI
		// can explain "why did this stage take 60s and then fall back?"
		// without forcing the operator to grep worker logs. We also capture
		// the error type to disambiguate timeouts from upstream HTTP errors
		// (deadline exceeded vs unexpected EOF vs 5xx, etc.).
		summaryOut["error"] = previewText(err.Error(), 500)
		summaryOut["error_type"] = fmt.Sprintf("%T", err)
		// For the insufficient-content case (scanned PDF without OCR, etc.)
		// we deliberately do NOT fall back to the first chunk's raw content,
		// since that chunk is typically just a bare markdown image reference
		// and surfacing it in the description is misleading.
		if errors.Is(err, errInsufficientSummaryContent) {
			knowledge.Description = ""
			knowledge.SummaryStatus = types.SummaryStatusFailed
			knowledge.UpdatedAt = time.Now()
			if updateErr := s.repo.UpdateKnowledge(ctx, knowledge); updateErr != nil {
				logger.Errorf(ctx, "Failed to mark summary as failed: %v", updateErr)
				summaryErr = updateErr
				return fmt.Errorf("failed to update knowledge: %w", updateErr)
			}
			summaryOut["fallback"] = "insufficient_content"
			summaryErr = err
			return nil
		}
		return handleRetryableSummaryFailure(err)
	}
	// Do not publish an answer derived from a superseded chunk or metadata
	// version. A user can explicitly refresh again from the latest revision.
	staleSummary, staleErr := summarySourceChanged(
		ctx, s.repo, s.chunkRepo, payload.TenantID, payload.KnowledgeID, summaryMetadataVersion, textChunks,
	)
	if staleErr != nil {
		logger.Errorf(ctx, "Failed to verify summary freshness for knowledge %s: %v", payload.KnowledgeID, staleErr)
		markSummaryFailed()
		summaryErr = staleErr
		return fmt.Errorf("verify summary freshness: %w", staleErr)
	}

View on GitHub (pinned to 988cbb0330)