plandex-ai/plandex · error · http

Error getting user:

Error message

Error getting user: 

What it means

When the request has no UserId, the handler looks up the account by email via db.GetUserByEmail(req.Email). Any error returned from that database call is answered with 500 "Error getting user: <err>". Note this is distinct from "user not found": GetUserByEmail returning (nil, nil) is handled as hasAccount=false, so a 500 means the lookup itself failed.

Source

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

		return
	}

	var req shared.CreateEmailVerificationRequest
	err = json.Unmarshal(body, &req)
	if err != nil {
		log.Printf("Error unmarshalling request: %v\n", err)
		http.Error(w, "Error unmarshalling request: "+err.Error(), http.StatusInternalServerError)
		return
	}
	req.Email = strings.ToLower(req.Email)

	var hasAccount bool
	if req.UserId == "" {
		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
		}

		hasAccount = user != nil
	} else {
		hasAccount = true

		user, err := db.GetUser(req.UserId)

		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 {
			log.Printf("User not found for id: %v\n", req.UserId)
			http.Error(w, "User not found", http.StatusNotFound)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the server log for the wrapped database error text to identify connection vs schema failure.
  2. Verify the database is running and reachable (DATABASE_URL / POSTGRES_HOST env, docker ps for the postgres container).
  3. Apply pending schema migrations so the users table matches what GetUserByEmail queries.
  4. Retry the signup/verification request — transient connection-pool exhaustion resolves on retry.
  5. If persistent, restart the server to rebuild DB connections and inspect connection-pool settings.
Defensive patterns

Strategy: retry

Validate before calling

// client-side: only send a syntactically valid, lowercased email so the DB lookup has a chance
email = strings.ToLower(strings.TrimSpace(email))
if email == "" || !strings.Contains(email, "@") {
    return errors.New("invalid email; fix before calling create-email-verification")
}

Try / catch

// Go client: retry on 500 with DB-flavored error text, back off between attempts
resp, err := client.Do(req)
if err != nil || resp.StatusCode == http.StatusInternalServerError {
    body, _ := io.ReadAll(resp.Body)
    if strings.Contains(string(body), "Error getting user") {
        return retryWithBackoff(req) // transient DB failure
    }
    return fmt.Errorf("user lookup failed permanently: %s", body)
}

Prevention

When it happens

Trigger: Postgres is down, unreachable, or the connection pool is exhausted; the users table is missing/migrated out of sync; a database timeout or context cancellation during the query; transient network failure between the server and the database.

Common situations: DB container stopped during local development; DATABASE_URL misconfigured after an env change; schema migrations not applied so the query references a missing column/table; connection limit hit under load during email-verification signup flows.

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