{"record":{"id":"df384c823ba88b49","repo":"vxcontrol/pentagi","slug":"failed-to-get-flow-tasks-w-df384c","errorCode":null,"errorMessage":"failed to get flow tasks: %w","messagePattern":"failed to get flow tasks: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":94,"sourceCode":"\tcase FlowStatusDetailSummary:\n\t\treturn t.buildSummary(ctx, verbose)\n\tcase FlowStatusDetailTasks:\n\t\treturn t.buildTasksList(ctx, verbose)\n\tcase FlowStatusDetailSubtasks:\n\t\treturn t.buildSubtasksList(ctx, action.TaskID.PtrInt64(), verbose)\n\tcase FlowStatusDetailRunning:\n\t\treturn t.buildRunningInfo(ctx, verbose)\n\tcase FlowStatusDetailPlanned:\n\t\treturn t.buildPlannedList(ctx, action.TaskID.PtrInt64(), verbose)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown detail level %q; use one of: summary, tasks, subtasks, running, planned\", action.Detail)\n\t}\n}\n\nfunc (t *flowStatusTool) buildSummary(ctx context.Context, verbose bool) (string, error) {\n\ttasks, err := t.db.GetFlowTasks(ctx, t.flowID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get flow tasks: %w\", err)\n\t}\n\n\tsubtasks, err := t.db.GetFlowSubtasks(ctx, t.flowID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get flow subtasks: %w\", err)\n\t}\n\n\ttaskCounts := map[string]int{\"created\": 0, \"running\": 0, \"waiting\": 0, \"finished\": 0, \"failed\": 0}\n\tvar activeTask *database.Task\n\tfor i, task := range tasks {\n\t\ttaskCounts[string(task.Status)]++\n\t\tif task.Status == database.TaskStatusRunning || task.Status == database.TaskStatusWaiting {\n\t\t\tactiveTask = &tasks[i]\n\t\t}\n\t}\n\n\tstCounts := map[string]int{\"created\": 0, \"running\": 0, \"waiting\": 0, \"finished\": 0, \"failed\": 0}\n\tvar activeST *database.Subtask","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L76-L112","documentation":"buildSummary fetches the flow's tasks via the database (GetFlowTasks) and wraps any failure with this message. This is a backend/data-access error — the tool arguments were fine, but the task list could not be loaded, so no status summary can be produced.","triggerScenarios":"GetFlowTasks returns an error: database connection refused, context canceled (flow request timed out), the flows/tasks table missing or the flow row deleted mid-query, or a Postgres error (deadlock, OOM, disk full).","commonSituations":"PostgreSQL container down or restarting during local Docker Compose runs; wrong DB credentials in .env; migration not applied so tables are absent; context deadline exceeded on very large flows; transient network blip between backend and DB.","solutions":["Check the wrapped cause in the error message and the backend logs for the underlying DB error.","Verify PostgreSQL is reachable and healthy (docker compose ps, connection env vars: DB host/port/user/password).","Confirm migrations ran (goose up) so the flow task tables exist.","Retry the tool call if the failure was transient (context timeout / connection reset).","Verify the flow ID still exists — the flow or its tasks may have been deleted."],"exampleFix":"// .env before\nDATABASE_HOST=localhost\nDATABASE_PORT=5433\n\n// .env after (match the running postgres service)\nDATABASE_HOST=localhost\nDATABASE_PORT=5432","handlingStrategy":"retry","validationCode":"func dbReachable(db *sql.DB) error {\n\tctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)\n\tdefer cancel()\n\treturn db.PingContext(ctx)\n}","typeGuard":null,"tryCatchPattern":"var out string\nvar lastErr error\nfor attempt := 0; attempt < 3; attempt++ {\n\tout, lastErr = tool.Handle(ctx, \"get_flow_status\", args)\n\tif lastErr == nil { return out, nil }\n\tif !strings.Contains(lastErr.Error(), \"failed to get flow\") { break }\n\ttime.Sleep(time.Duration(1<<attempt) * 100 * time.Millisecond)\n}\nreturn lastErr","preventionTips":["Monitor PostgreSQL health before invoking flow tools (docker compose ps / pg_isready)","Verify DB env vars and that goose migrations have run","Set generous context timeouts for large flows to avoid cancellation mid-query","Retry transient DB errors with exponential backoff","Check the flow still exists if deletions happen concurrently"],"tags":["database","postgres","data-access","flow-status"],"backgroundTag":"database-query-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}