{"record":{"id":"37ca1224edc97822","repo":"plandex-ai/plandex","slug":"error-getting-plan-subtasks-v","errorCode":null,"errorMessage":"error getting plan subtasks: %v","messagePattern":"error getting plan subtasks: (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/model/plan/tell_load.go","lineNumber":304,"sourceCode":"\t\t\t\tconvo = append(convo, promptMsg)\n\t\t\t}\n\n\t\t\terrCh <- nil\n\t\t}()\n\n\t\tgo func() {\n\t\t\tdefer func() {\n\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\tlog.Printf(\"panic in getPlanSubtasks: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\terrCh <- fmt.Errorf(\"error getting plan subtasks: %v\\n%s\", r, debug.Stack())\n\t\t\t\t\truntime.Goexit() // don't allow outer function to continue and double-send to channel\n\t\t\t\t}\n\t\t\t}()\n\n\t\t\tres, err := db.GetPlanSubtasks(auth.OrgId, planId)\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"Error getting plan subtasks: %v\\n\", err)\n\t\t\t\terrCh <- fmt.Errorf(\"error getting plan subtasks: %v\", err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tsubtasks = res\n\t\t\terrCh <- nil\n\t\t}()\n\n\t\tfor i := 0; i < 4; i++ {\n\t\t\terr = <-errCh\n\t\t\tif err != nil {\n\t\t\t\tgo notify.NotifyErr(notify.SeverityError, fmt.Errorf(\"error loading plan: %v\", err))\n\n\t\t\t\tactive.StreamDoneCh <- &shared.ApiError{\n\t\t\t\t\tType:   shared.ApiErrorTypeOther,\n\t\t\t\t\tStatus: http.StatusInternalServerError,\n\t\t\t\t\tMsg:    fmt.Sprintf(\"Error loading plan: %v\", err),\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t}","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/plan/tell_load.go#L286-L322","documentation":"Non-panic variant of the subtask load failure: db.GetPlanSubtasks(auth.OrgId, planId) returned an error, which is logged and wrapped as 'error getting plan subtasks: %v' and sent on errCh in tell_load.go. It indicates the database could not return the plan's subtask rows.","triggerScenarios":"GetPlanSubtasks fails: DB connectivity issue, invalid orgId/planId pair, schema mismatch on the subtasks table, or query timeout.","commonSituations":"Postgres outage or pool exhaustion; plan belongs to a different org than auth.OrgId; missing migration for subtasks table.","solutions":["Inspect the wrapped DB error in the server log","Verify the plan exists under auth.OrgId","Confirm database connectivity and schema migrations","Retry after transient DB issues are resolved"],"exampleFix":"// before\nres, err := db.GetPlanSubtasks(auth.OrgId, planId)\nif err != nil {\n    errCh <- fmt.Errorf(\"error getting plan subtasks: %v\", err)\n    return\n}\n// after\nres, err := db.GetPlanSubtasks(auth.OrgId, planId)\nif err != nil {\n    if errors.Is(err, sql.ErrNoRows) {\n        errCh <- nil // plan has no subtasks yet\n    } else {\n        errCh <- fmt.Errorf(\"error getting plan subtasks: %w\", err)\n    }\n    return\n}","handlingStrategy":"try-catch","validationCode":"if auth.OrgId == \"\" || planId == \"\" {\n    return fmt.Errorf(\"missing orgId or planId\")\n}\nif err := db.Ping(); err != nil {\n    return fmt.Errorf(\"database unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := db.GetPlanSubtasks(auth.OrgId, planId)\nif err != nil {\n    log.Printf(\"Error getting plan subtasks: %v\", err)\n    errCh <- fmt.Errorf(\"error getting plan subtasks: %w\", err)\n    return\n}","preventionTips":["Confirm the plan belongs to auth.OrgId before loading","Keep schema migrations in sync with query code","Add DB health checks to startup","Distinguish no-rows from hard errors where appropriate"],"tags":["database","postgres","plan-subtasks"],"backgroundTag":"database-query-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}