plandex-ai/plandex · error

Error getting user:

Error message

Error getting user: 

What it means

To prevent duplicate members, the handler looks up an existing user by email with db.GetUserByEmail(req.Email). If that query fails, the handler responds 500 with 'Error getting user: <err>'. Like the other 5xx paths, this reflects a database-layer failure rather than bad input (a 'not found' result returns nil user, not an error).

Source

Thrown at app/server/handlers/invites.go:93

	split := strings.Split(req.Email, "@")
	if len(split) != 2 {
		log.Printf("Invalid email: %v\n", req.Email)
		http.Error(w, "Invalid email: "+req.Email, http.StatusBadRequest)
		return
	}
	domain := &split[1]

	if org.AutoAddDomainUsers && org.Domain == domain {
		log.Printf("User already has access to org via domain: %v\n", domain)
		http.Error(w, "User already has access to org via domain: "+*domain, http.StatusBadRequest)
	}

	// ensure user with this email isn't already in the org
	user, err := db.GetUserByEmail(req.Email)

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

	if user != nil {
		isMember, err := db.ValidateOrgMembership(user.Id, auth.OrgId)

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

		if isMember {
			log.Println("User is already a member of org")
			http.Error(w, "User is already a member of org", http.StatusBadRequest)
			return
		}
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the cause after 'Error getting user: ' in the response/log to identify the concrete DB error
  2. Confirm Postgres health and DATABASE_URL reachability; check connection-pool limits under load
  3. Run pending database migrations, then retry the invite
  4. Simply retry on transient errors; escalate to DB inspection (logs, pg_stat_activity) if it persists
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: verify DB-dependent endpoints are healthy before bulk invites
if err := client.HealthCheck(ctx); err != nil {
    return fmt.Errorf("server database unhealthy, deferring invites: %w", err)
}

Try / catch

err := client.InviteUser(ctx, email, roleID)
if err != nil && strings.Contains(err.Error(), "Error getting user") {
    // 500 from DB lookup — retry with backoff for transient failures
    return retryWithBackoff(func() error { return client.InviteUser(ctx, email, roleID) })
}

Prevention

When it happens

Trigger: db.GetUserByEmail fails due to Postgres unreachability, connection-pool exhaustion, query timeout, missing/out-of-date users table schema, or a serialization issue on the row.

Common situations: Database outage or failover during the invite; DATABASE_URL misconfig; migrations not applied after an upgrade; transient network errors between server and DB 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


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