plandex-ai/plandex · error
Error archiving plan:
Error message
Error archiving plan:
What it means
The SQL UPDATE setting plans.archived_at = NOW() failed at the database level, and the handler returns HTTP 500 with 'Error archiving plan: <err>'. This indicates a DB-level problem, not a client payload problem.
Source
Thrown at app/server/handlers/plans_changes.go:460
log.Println("planId: ", planId)
plan := authorizePlanArchive(w, planId, auth)
if plan == nil {
return
}
if plan.ArchivedAt != nil {
log.Println("Plan already archived")
http.Error(w, "Plan already archived", http.StatusBadRequest)
return
}
res, err := db.Conn.Exec("UPDATE plans SET archived_at = NOW() WHERE id = $1", planId)
if err != nil {
log.Printf("Error archiving plan: %v\n", err)
http.Error(w, "Error archiving plan: "+err.Error(), http.StatusInternalServerError)
return
}
rowsAffected, err := res.RowsAffected()
if err != nil {
log.Printf("Error getting rows affected: %v\n", err)
http.Error(w, "Error getting rows affected: "+err.Error(), http.StatusInternalServerError)
return
}
if rowsAffected == 0 {
log.Println("Plan not found")
http.Error(w, "Not found", http.StatusNotFound)
return
}
log.Println("Successfully archived plan", planId)
}View on GitHub (pinned to e2d772072e)
Solutions
- Read the appended err.Error() — it names the exact Postgres failure
- Check DB connectivity/health and app logs around the timestamp
- Verify the archived_at column exists (run pending migrations)
- Confirm the app's DB role has UPDATE on plans; retry once connectivity is restored
Example fix
-- if schema drift is the cause ALTER TABLE plans ADD COLUMN IF NOT EXISTS archived_at TIMESTAMPTZ;
Defensive patterns
Strategy: retry
Validate before calling
if (!planId) throw new Error('planId required');
const plan = await getPlan(planId); // fail early if plan/DB unreachable
if (plan.archivedAt) throw new Error('already archived'); Type guard
function isDbConnectivityError(msg) { return /connection refused|dial tcp|too many connections|timeout/i.test(msg); } Try / catch
try { await archivePlan(planId); } catch (e) { if (e.status === 500 && isDbConnectivityError(e.message)) await retryWithBackoff(() => archivePlan(planId)); else throw e; } Prevention
- Monitor DB health; alert on connection/pool exhaustion
- Keep schema migrations applied (archived_at column must exist)
- Grant the app role UPDATE on plans
- Only retry transient-looking 500s (connectivity/timeout), not permission errors
When it happens
Trigger: db.Conn.Exec('UPDATE plans SET archived_at = NOW() WHERE id = $1', planId) errors: database unreachable, connection pool exhausted, permission denied on UPDATE, table/schema drift (archived_at column missing), or query timeout.
Common situations: Postgres restarted or network blip between app and DB; migration not applied so archived_at column doesn't exist; app DB user lacks UPDATE privilege on plans; pool saturation under load.
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 getting rows affected:
- error updating plan total replies: %v
- error getting plan: %v
- error setting plan status: %v
- error renaming plan: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/053dc8b7c34005fe.
Report an issue: GitHub.