{"record":{"id":"33adb24c9d5542f6","repo":"vxcontrol/pentagi","slug":"failed-to-get-flow-term-log-w","errorCode":null,"errorMessage":"failed to get flow term log: %w","messagePattern":"failed to get flow term log: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/flow.go","lineNumber":1235,"sourceCode":") (*flowProviderWorkers, error) {\n\talw, err := cnts.alc.GetFlowAgentLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow agent log: %w\", err)\n\t}\n\n\tmlw, err := cnts.mlc.GetFlowMsgLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow msg log: %w\", err)\n\t}\n\n\tslw, err := cnts.slc.GetFlowSearchLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow search log: %w\", err)\n\t}\n\n\ttlw, err := cnts.tlc.GetFlowTermLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow term log: %w\", err)\n\t}\n\n\tvslw, err := cnts.vslc.GetFlowVectorStoreLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow vector store log: %w\", err)\n\t}\n\n\ttclw, err := cnts.tclc.GetFlowToolCallLog(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow tool call log: %w\", err)\n\t}\n\n\tsw, err := cnts.sc.GetFlowScreenshot(ctx, flowID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get flow screenshot: %w\", err)\n\t}\n\n\treturn &flowProviderWorkers{","sourceCodeStart":1217,"sourceCodeEnd":1253,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/flow.go#L1217-L1253","documentation":"Wraps a failure from cnts.tlc.GetFlowTermLog(ctx, flowID) — the terminal-log worker could not be created for the flow. Returned with %w so the root cause (DB/service error) remains inspectable. Assembly of flowProviderWorkers stops at this point.","triggerScenarios":"Retrieving flow logs when the terminal-log store lookup for flowID fails (missing rows/connection error).","commonSituations":"Terminal session data purged or flow deleted; DB unreachable; migration drift missing terminal-log tables.","solutions":["Check the wrapped cause for the specific storage error.","Validate the flowID exists and has not been deleted.","Ensure migrations creating terminal-log tables have run.","Retry transient failures; verify DB health."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var exists bool\nerr := db.QueryRow(\"SELECT EXISTS(SELECT 1 FROM flows WHERE id=$1)\", flowID).Scan(&exists)\nif err != nil || !exists { /* abort with 404 */ }","typeGuard":"func isTermLogError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to get flow term log\")\n}","tryCatchPattern":"tlw, err := cnts.tlc.GetFlowTermLog(ctx, flowID)\nif err != nil {\n\tif errors.Is(err, sql.ErrNoRows) { /* return empty log */ }\n\treturn nil, fmt.Errorf(\"failed to get flow term log: %w\", err)\n}","preventionTips":["Check flow existence before log retrieval.","Ensure terminal-log migrations have run.","Watch for flow deletion races; use soft deletes if needed.","Retry transient connection errors."],"tags":["database","terminal-logs","error-wrapping"],"backgroundTag":"data-source-query-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}