plandex-ai/plandex · error
error getting default plan config: %v
Error message
error getting default plan config: %v
What it means
GetDefaultPlanConfig wraps a failure of Conn.Get(&config, "SELECT default_plan_config FROM users WHERE id = $1", userId) with this message. sqlx Get expects exactly one row, so a userId with no users row (sql.ErrNoRows) also produces this error, alongside connection and scan failures.
Source
Thrown at app/server/db/plan_config_helpers.go:47
`
_, err := Conn.Exec(query, config, planId)
if err != nil {
return fmt.Errorf("error storing plan config: %v", err)
}
return nil
}
func GetDefaultPlanConfig(userId string) (*shared.PlanConfig, error) {
query := "SELECT default_plan_config FROM users WHERE id = $1"
var config shared.PlanConfig
err := Conn.Get(&config, query, userId)
if err != nil {
return nil, fmt.Errorf("error getting default plan config: %v", err)
}
return &config, nil
}
func StoreDefaultPlanConfig(userId string, config *shared.PlanConfig, tx *sqlx.Tx) error {
query := `
UPDATE users SET default_plan_config = $1 WHERE id = $2
`
_, err := tx.Exec(query, config, userId)
if err != nil {
return fmt.Errorf("error storing default plan config: %v", err)
}
return nil
}View on GitHub (pinned to e2d772072e)
Solutions
- Check the wrapped cause: 'no rows in result set' means the userId is unknown — validate the user session/account exists first
- If scanning fails, inspect users.default_plan_config for malformed JSON and repair or reset it
- For connection errors, verify DATABASE_URL and Postgres health, then retry
- Consider falling back to a zero-value PlanConfig when the user has no row, depending on desired behavior
Example fix
// before
config, err := GetDefaultPlanConfig(userId)
if err != nil { return err }
// after: treat missing user config as empty default
config, err := GetDefaultPlanConfig(userId)
if err != nil {
if strings.Contains(err.Error(), "no rows in result set") {
config = &shared.PlanConfig{}
} else {
return err
}
} Defensive patterns
Strategy: fallback
Validate before calling
var exists bool
err := Conn.Get(&exists, "SELECT EXISTS(SELECT 1 FROM users WHERE id=$1)", userId)
if err != nil || !exists {
// invalid session/user — handle before querying the config
} Try / catch
config, err := GetDefaultPlanConfig(userId)
if err != nil {
if strings.Contains(err.Error(), "no rows in result set") {
config = &shared.PlanConfig{} // fallback default
} else {
return nil, err
}
} Prevention
- Verify the user id from a trusted session, never client-supplied alone
- Use NOT NULL / DEFAULT '{}' for users.default_plan_config to avoid null-scan surprises
- Validate stored config JSON on write so reads never hit scan errors
- Probe DB health at startup to distinguish infra errors from data errors
When it happens
Trigger: Called from LoadContexts, UpdateContexts, GetDefaultPlanConfigHandler, or CreatePlan with a userId absent from the users table, a broken DB connection, or a default_plan_config value that fails to scan into shared.PlanConfig.
Common situations: User account deleted or id mismatched while a session still references it; fresh environment where the user row was never created; corrupted default_plan_config JSON; Postgres unavailable.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- error getting plan config: %v
- error listing org roles: %v
- error storing plan config: %v
- error getting default plan config: %v
- error adding plan context tokens: %v
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/e16b6c11b3c9b48a.
Report an issue: GitHub.