{"record":{"id":"ceeb81577bd62006","repo":"Tencent/WeKnora","slug":"get-chat-model-w","errorCode":null,"errorMessage":"get chat model: %w","messagePattern":"get chat model: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_process.go","lineNumber":1223,"sourceCode":"\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\n\t// Generate summary\n\tsummary, err := s.getSummary(ctx, chatModel, knowledge, textChunks)\n\tif err != nil {\n\t\tlogger.Errorf(ctx, \"Failed to generate summary for knowledge %s: %v\", payload.KnowledgeID, err)\n\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) {","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_process.go#L1205-L1241","documentation":"Thrown when modelService.GetChatModel fails to resolve the chat model configured for summarization (kb summary model). Model resolution failures share the same retry budget and terminal first-chunk fallback as LLM request failures.","triggerScenarios":"Thrown at internal/application/service/knowledge_process.go:1223 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the summary model ID exists and is enabled for the tenant","Check model provider credentials/configuration","After fixing config, retry summary generation; fallback keeps knowledge usable meanwhile"],"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"}