plandex-ai/plandex · error
error getting branches: %v
Error message
error getting branches: %v
What it means
In ListPlansRunningHandler's second goroutine, db.ListBranchesForPlans(auth.OrgId, planIds) failed. The error is wrapped as 'error getting branches' and sent to errCh, resulting in HTTP 500. The DB layer returned an error executing the branch lookup for the org's plans.
Source
Thrown at app/server/handlers/plans_crud.go:477
if err != nil {
errCh <- fmt.Errorf("error getting recent model streams: %v", err)
return
}
errCh <- nil
}()
go func() {
defer func() {
if r := recover(); r != nil {
log.Printf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
errCh <- fmt.Errorf("panic in ListPlansRunningHandler: %v\n%s", r, debug.Stack())
runtime.Goexit() // don't allow outer function to continue and double-send to channel
}
}()
var err error
branches, err = db.ListBranchesForPlans(auth.OrgId, planIds)
if err != nil {
errCh <- fmt.Errorf("error getting branches: %v", err)
return
}
errCh <- nil
}()
for i := 0; i < 2; i++ {
err := <-errCh
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
res := shared.ListPlansRunningResponse{
Branches: []*shared.Branch{},
StreamStartedAtByBranchId: map[string]time.Time{},
StreamFinishedAtByBranchId: map[string]time.Time{},View on GitHub (pinned to e2d772072e)
Solutions
- Inspect the wrapped cause to identify the DB-level failure.
- Confirm DB connectivity and credentials for the server process.
- Verify the branches schema/migration is applied and orgId/planIds values are valid.
- Check Postgres logs for the failing statement.
Example fix
// before
branches, err = db.ListBranchesForPlans(auth.OrgId, planIds)
// after
branches, err = db.ListBranchesForPlans(auth.OrgId, planIds)
if err != nil {
log.Printf("ListBranchesForPlans org=%s plans=%v: %v", auth.OrgId, planIds, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// Go
if auth.OrgId == "" {
http.Error(w, "missing org id", http.StatusBadRequest)
return
} Type guard
func branchesQueryable(orgId string, planIds []string) bool { return orgId != "" && len(planIds) > 0 } Try / catch
branches, err := db.ListBranchesForPlans(auth.OrgId, planIds)
if err != nil {
log.Printf("branches query failed: %v", err)
http.Error(w, "failed to load branches", http.StatusInternalServerError)
return
} Prevention
- Verify org and plan IDs are valid before querying.
- Keep branch-table migrations in sync across environments.
- Monitor DB health; surface wrapped causes in logs.
- Retry transient DB errors with backoff.
When it happens
Trigger: The ListBranchesForPlans query fails: DB unreachable, connection pool exhausted, invalid org ID, empty planIds producing a malformed SQL IN clause, or schema mismatch in the branches table.
Common situations: Database downtime or credential rotation; branches migration missing in the target environment; plan IDs referencing deleted rows under strict FK/permissions.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- error adding plan context tokens: %v
- error adding org member: %v
- error listing org roles: %v
- error adding org user: %v
- error getting plan config: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/edeeb88afdc85512.
Report an issue: GitHub.