{"record":{"id":"77302d1ea3912dfa","repo":"Tencent/WeKnora","slug":"failed-to-update-knowledge-w-77302d","errorCode":null,"errorMessage":"failed to update knowledge: %w","messagePattern":"failed to update knowledge: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_process.go","lineNumber":1248,"sourceCode":"\t\t// Surface the underlying LLM/IO error on the span so the trace UI\n\t\t// can explain \"why did this stage take 60s and then fall back?\"\n\t\t// without forcing the operator to grep worker logs. We also capture\n\t\t// the error type to disambiguate timeouts from upstream HTTP errors\n\t\t// (deadline exceeded vs unexpected EOF vs 5xx, etc.).\n\t\tsummaryOut[\"error\"] = previewText(err.Error(), 500)\n\t\tsummaryOut[\"error_type\"] = fmt.Sprintf(\"%T\", err)\n\t\t// For the insufficient-content case (scanned PDF without OCR, etc.)\n\t\t// we deliberately do NOT fall back to the first chunk's raw content,\n\t\t// since that chunk is typically just a bare markdown image reference\n\t\t// and surfacing it in the description is misleading.\n\t\tif errors.Is(err, errInsufficientSummaryContent) {\n\t\t\tknowledge.Description = \"\"\n\t\t\tknowledge.SummaryStatus = types.SummaryStatusFailed\n\t\t\tknowledge.UpdatedAt = time.Now()\n\t\t\tif updateErr := s.repo.UpdateKnowledge(ctx, knowledge); updateErr != nil {\n\t\t\t\tlogger.Errorf(ctx, \"Failed to mark summary as failed: %v\", updateErr)\n\t\t\t\tsummaryErr = updateErr\n\t\t\t\treturn fmt.Errorf(\"failed to update knowledge: %w\", updateErr)\n\t\t\t}\n\t\t\tsummaryOut[\"fallback\"] = \"insufficient_content\"\n\t\t\tsummaryErr = err\n\t\t\treturn nil\n\t\t}\n\t\treturn handleRetryableSummaryFailure(err)\n\t}\n\t// Do not publish an answer derived from a superseded chunk or metadata\n\t// version. A user can explicitly refresh again from the latest revision.\n\tstaleSummary, staleErr := summarySourceChanged(\n\t\tctx, s.repo, s.chunkRepo, payload.TenantID, payload.KnowledgeID, summaryMetadataVersion, textChunks,\n\t)\n\tif staleErr != nil {\n\t\tlogger.Errorf(ctx, \"Failed to verify summary freshness for knowledge %s: %v\", payload.KnowledgeID, staleErr)\n\t\tmarkSummaryFailed()\n\t\tsummaryErr = staleErr\n\t\treturn fmt.Errorf(\"verify summary freshness: %w\", staleErr)\n\t}","sourceCodeStart":1230,"sourceCodeEnd":1266,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_process.go#L1230-L1266","documentation":"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.","triggerScenarios":"Thrown at internal/application/service/knowledge_process.go:1248 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and retry the summary task","Verify the knowledge row exists and is not locked or deleted mid-processing","Inspect the wrapped error for constraint violations"],"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"}