{"record":{"id":"4369fb5ffd4e63cd","repo":"Tencent/WeKnora","slug":"failed-to-create-summary-chunk-w","errorCode":null,"errorMessage":"failed to create summary chunk: %w","messagePattern":"failed to create summary chunk: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_process.go","lineNumber":1325,"sourceCode":"\t\t\tTenantID:        knowledge.TenantID,\n\t\t\tKnowledgeID:     knowledge.ID,\n\t\t\tKnowledgeBaseID: knowledge.KnowledgeBaseID,\n\t\t\tContent:         fmt.Sprintf(\"# Summary\\n%s\", summary),\n\t\t\tChunkIndex:      maxChunkIndex + 1,\n\t\t\tIsEnabled:       true,\n\t\t\tCreatedAt:       time.Now(),\n\t\t\tUpdatedAt:       time.Now(),\n\t\t\tStartAt:         0,\n\t\t\tEndAt:           0,\n\t\t\tChunkType:       types.ChunkTypeSummary,\n\t\t\tParentChunkID:   textChunks[0].ID,\n\t\t}\n\n\t\t// Save summary chunk\n\t\tif err := s.chunkService.CreateChunks(ctx, []*types.Chunk{summaryChunk}); err != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to create summary chunk: %v\", err)\n\t\t\tsummaryErr = err\n\t\t\treturn fmt.Errorf(\"failed to create summary chunk: %w\", err)\n\t\t}\n\n\t\t// Index summary chunk\n\t\ttenantInfo, err := s.tenantRepo.GetTenantByID(ctx, payload.TenantID)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to get tenant info: %v\", err)\n\t\t\tsummaryErr = err\n\t\t\treturn fmt.Errorf(\"failed to get tenant info: %w\", err)\n\t\t}\n\t\tctx = context.WithValue(ctx, types.TenantInfoContextKey, tenantInfo)\n\n\t\tretrieveEngine, err := retriever.CreateRetrieveEngineForKB(\n\t\t\tctx, s.retrieveEngine, s.ownership, tenantInfo.ID, kb.VectorStoreID)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to init retrieve engine: %v\", err)\n\t\t\tsummaryErr = err\n\t\t\treturn fmt.Errorf(\"failed to init retrieve engine: %w\", err)\n\t\t}","sourceCodeStart":1307,"sourceCodeEnd":1343,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_process.go#L1307-L1343","documentation":"Thrown when chunkService.CreateChunks fails to persist the newly generated summary chunk (ChunkTypeSummary, parented to the first text chunk). The summary text exists but could not be stored, so indexing is skipped.","triggerScenarios":"Thrown at internal/application/service/knowledge_process.go:1325 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check database connectivity and retry the summary task","Verify chunk table constraints (index, parent ID, knowledge ID)","Inspect the wrapped error from CreateChunks for the failing insert"],"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"}