{"record":{"id":"0c7b30580081aef2","repo":"Tencent/WeKnora","slug":"save-terminal-summary-fallback-w","errorCode":null,"errorMessage":"save terminal summary fallback: %w","messagePattern":"save terminal summary fallback: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_process.go","lineNumber":1207,"sourceCode":"\t\t)\n\t\tif staleErr != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to verify summary fallback freshness for knowledge %s: %v\",\n\t\t\t\tpayload.KnowledgeID, staleErr)\n\t\t\tmarkSummaryFailed()\n\t\t\tsummaryErr = staleErr\n\t\t\treturn fmt.Errorf(\"verify summary fallback freshness: %w\", staleErr)\n\t\t}\n\t\tif stale {\n\t\t\tlogger.Infof(ctx, \"Discarding stale summary fallback for knowledge %s\", payload.KnowledgeID)\n\t\t\tsummaryOut[\"skipped\"] = \"content_revision_changed\"\n\t\t\treturn nil\n\t\t}\n\n\t\tfallback := applyRetryableSummaryFailureState(knowledge, textChunks, false)\n\t\tif updateErr := s.repo.UpdateKnowledge(ctx, knowledge); updateErr != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to save terminal summary fallback: %v\", updateErr)\n\t\t\tsummaryErr = updateErr\n\t\t\treturn fmt.Errorf(\"save terminal summary fallback: %w\", updateErr)\n\t\t}\n\t\tif fallback == \"\" {\n\t\t\tsummaryOut[\"fallback\"] = \"empty\"\n\t\t} else {\n\t\t\tsummaryOut[\"fallback\"] = \"first_chunk\"\n\t\t}\n\t\tsummaryOut[\"fallback_chars\"] = len([]rune(fallback))\n\t\treturn fmt.Errorf(\"summary generation exhausted retries: %w\", generationErr)\n\t}\n\n\t// Initialize chat model for summary. Model resolution failures use the same\n\t// retry budget and terminal first-chunk fallback as LLM request failures.\n\tchatModel, err := s.modelService.GetChatModel(ctx, kb.SummaryModelID)\n\tif err != nil {\n\t\tlogger.Errorf(ctx, \"Failed to get chat model: %v\", err)\n\t\treturn handleRetryableSummaryFailure(fmt.Errorf(\"get chat model: %w\", err))\n\t}\n","sourceCodeStart":1189,"sourceCodeEnd":1225,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_process.go#L1189-L1225","documentation":"Thrown when repo.UpdateKnowledge fails while saving applyRetryableSummaryFailureState — the terminal state that records summary-generation exhaustion with a first-chunk fallback. The generation result is lost because the failure state could not be persisted.","triggerScenarios":"Thrown at internal/application/service/knowledge_process.go:1207 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and retry the summary task","Verify the knowledge row is writable and not locked","The summary stage will re-attempt and re-mark the failure state"],"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"}