plandex-ai/plandex · error · http

Error getting org user config:

Error message

Error getting org user config: 

What it means

GetOrgUserConfigHandler fails at app/server/handlers/sessions.go:295-300 when db.GetOrgUserConfig(auth.User.Id, auth.OrgId) returns an error fetching the organization-user configuration row. This is a database-layer failure: no/failed query, connection issue, or scan error mapping the row into the config struct.

Source

Thrown at app/server/handlers/sessions.go:299

		return
	}

	log.Println("Successfully signed out")
}

func GetOrgUserConfigHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for GetOrgUserConfigHandler")

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	orgUserConfig, err := db.GetOrgUserConfig(auth.User.Id, auth.OrgId)

	if err != nil {
		log.Printf("Error getting org user config: %v\n", err)
		http.Error(w, "Error getting org user config: "+err.Error(), http.StatusInternalServerError)
		return
	}

	bytes, err := json.Marshal(orgUserConfig)

	if err != nil {
		log.Printf("Error marshalling response: %v\n", err)
		http.Error(w, "Error marshalling response: "+err.Error(), http.StatusInternalServerError)
		return
	}

	w.Write(bytes)
}

func UpdateOrgUserConfigHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for UpdateOrgUserConfigHandler")

	auth := Authenticate(w, r, true)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the logged 'Error getting org user config: ...' text to distinguish connection errors from scan/SQL errors
  2. Run pending database migrations and verify the org_user_config table/columns exist
  3. Verify Postgres connectivity and pool health from the app host
  4. Check that GetOrgUserConfig's scan destinations match the current table column types

Example fix

// before
if err != nil {
	http.Error(w, "Error getting org user config: "+err.Error(), http.StatusInternalServerError)
	return
}
// after
if err != nil {
	if errors.Is(err, sql.ErrNoRows) {
		cfg := shared.DefaultOrgUserConfig() // return defaults instead of 500
		writeJSON(w, cfg)
		return
	}
	log.Printf("Error getting org user config: %v\n", err)
	http.Error(w, "Error getting org user config", http.StatusInternalServerError)
	return
}
Defensive patterns

Strategy: retry

Validate before calling

// caller-side readiness probe
if err := db.Conn.Ping(ctx); err != nil {
	return fmt.Errorf("database unavailable: %w", err)
}

Type guard

func isMissingSchemaError(err error) bool {
	var pgErr *pgconn.PgError
	return errors.As(err, &pgErr) && (pgErr.Code == "42P01" || pgErr.Code == "42703") // undefined table/column
}

Try / catch

cfg, err := db.GetOrgUserConfig(userID, orgID)
if err != nil {
	if isMissingSchemaError(err) {
		return nil, fmt.Errorf("schema out of date; run migrations: %w", err)
	}
	if isTransientDBError(err) {
		// retry once with backoff
		time.Sleep(time.Second)
		return db.GetOrgUserConfig(userID, orgID)
	}
	return nil, err
}

Prevention

When it happens

Trigger: Authenticated GET of org user config where the underlying SELECT fails: database unreachable, org_user_config table/columns missing, row cannot be scanned into the expected struct, or the (user_id, org_id) lookup errors.

Common situations: Migrations not applied after a schema change, Postgres down or connection pool exhausted, column type changed so rows.Scan fails, or stale app deployed against a newer schema.

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


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/c7c15c641acee2cb. Report an issue: GitHub.