plandex-ai/plandex · error
Error getting default plan config
Error message
Error getting default plan config
What it means
GetDefaultPlanConfigHandler returns HTTP 500 when db.GetDefaultPlanConfig(auth.User.Id) errors. It fetches the user's default plan settings; failures are DB-side (query, scan, or connectivity) since only the authenticated user's ID is used.
Source
Thrown at app/server/handlers/plan_config.go:103
http.Error(w, "Error storing plan config", http.StatusInternalServerError)
return
}
log.Println("UpdatePlanConfigHandler processed successfully")
}
func GetDefaultPlanConfigHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Received request for GetDefaultPlanConfigHandler")
auth := Authenticate(w, r, true)
if auth == nil {
return
}
config, err := db.GetDefaultPlanConfig(auth.User.Id)
if err != nil {
log.Println("Error getting default plan config: ", err)
http.Error(w, "Error getting default plan config", http.StatusInternalServerError)
return
}
res := shared.GetDefaultPlanConfigResponse{
Config: config,
}
bytes, err := json.Marshal(res)
if err != nil {
log.Println("Error marshalling response: ", err)
http.Error(w, "Error marshalling response", http.StatusInternalServerError)
return
}
w.Write(bytes)
log.Println("GetDefaultPlanConfigHandler processed successfully")
}
View on GitHub (pinned to e2d772072e)
Solutions
- Check server logs for "Error getting default plan config: <err>" to see the cause
- Run pending migrations so the default-config table matches the model
- Treat missing rows as an empty default config instead of an error (sql.ErrNoRows handling)
- Repair or reset corrupt default-config rows for the affected user
Example fix
// before
config, err := db.GetDefaultPlanConfig(auth.User.Id)
if err != nil {
http.Error(w, "Error getting default plan config", http.StatusInternalServerError)
return
}
// after
config, err := db.GetDefaultPlanConfig(auth.User.Id)
if errors.Is(err, sql.ErrNoRows) {
config = shared.DefaultPlanConfig()
} else if err != nil {
http.Error(w, "Error getting default plan config", http.StatusInternalServerError)
return
} Defensive patterns
Strategy: try-catch
Validate before calling
// client: ensure user is authenticated first
if (!authToken) return;
const res = await fetch(base + '/plans/default-config', { headers: { Authorization: 'Bearer ' + authToken } });
if (res.status === 500) console.error('default config lookup failed; check server DB logs'); Try / catch
try {
const cfg = await getDefaultPlanConfig();
} catch (e) {
if (e.status === 500) { /* fall back to client defaults and report server issue */ }
else throw e;
} Prevention
- Return empty defaults when the user has no stored config (sql.ErrNoRows)
- Run migrations on every deploy
- Validate stored default-config JSON integrity
- Monitor DB availability with health checks
When it happens
Trigger: GET default plan config when the user_settings/default-config row for auth.User.Id cannot be read, the DB is unreachable, or the stored default config fails to scan/deserialize (e.g. corrupt JSON).
Common situations: Brand-new user with no row and the query not treating missing-row as empty, schema drift after upgrade, manually edited default config containing invalid JSON, transient Postgres outages.
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 current plan state params: %v
- error getting contexts: %v
- error loading plan: %v
- error validating project
- error validating plan membership
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/2291cf3edbb122a9.
Report an issue: GitHub.