plandex-ai/plandex · error

Error getting org: {err.Error()}

Error message

Error getting org: {err.Error()}

What it means

ListUsersHandler loads the org record with db.GetOrg(auth.OrgId) before checking trial status. Any DB error (unreachable database, missing org row, scan/schema mismatch) is returned as 500 with the raw error text appended: 'Error getting org: <err>'. Unlike the settings handlers, this leaks the underlying error string to the client.

Source

Thrown at app/server/handlers/users.go:38

	if os.Getenv("GOENV") == "development" && os.Getenv("LOCAL_MODE") == "1" {
		writeApiError(w, shared.ApiError{
			Type:   shared.ApiErrorTypeOther,
			Status: http.StatusForbidden,
			Msg:    "Local mode is not supported for user management",
		})
		return
	}

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

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

	if org.IsTrial {
		writeApiError(w, shared.ApiError{
			Type:   shared.ApiErrorTypeTrialActionNotAllowed,
			Status: http.StatusForbidden,
			Msg:    "Trial user can't list users",
		})
		return
	}

	users, err := db.ListUsers(auth.OrgId)
	if err != nil {
		log.Println("Error listing users: ", err)
		http.Error(w, "Error listing users: "+err.Error(), http.StatusInternalServerError)
		return
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the response/server log — this error includes the raw DB error text
  2. Verify DATABASE_URL points at the correct, healthy database
  3. Confirm the org ID from the auth token exists in the orgs table
  4. Apply pending migrations so the orgs schema matches the code
  5. Retry once the DB is reachable
Defensive patterns

Strategy: retry

Validate before calling

const res = await fetch(`${base}/org/users`, { headers: authHeaders });
if (res.status === 500 && /Error getting org/.test(await res.text())) {
  await checkDbHealthOrRetry();
}

Try / catch

try {
  return await api.listUsers();
} catch (e) {
  if (e.status >= 500) await backoffRetry(() => api.listUsers(), 3);
  else if (e.status === 403 && e.type === 'trial_action_not_allowed') upgradeOrg();
  else throw e;
}

Prevention

When it happens

Trigger: GET the users list endpoint when the orgs lookup fails: DB down, org row deleted while the auth session still references its ID, column mismatch after a migration, or connection pool exhaustion.

Common situations: Server pointed at the wrong DATABASE_URL after a config change; org deleted during cleanup while tokens remain valid; schema drift from an unapplied migration.

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/752d36aa9c022c1c. Report an issue: GitHub.