plandex-ai/plandex · error · http

Error validating email verification:

Error message

Error validating email verification: 

What it means

This error is returned when db.ValidateEmailVerification fails with an error that is NOT the known InvalidOrExpiredPinError sentinel. The handler responds with HTTP 500 prefixed 'Error validating email verification: '. It signals an unexpected backend problem during the lookup — most commonly a database connectivity or query failure — rather than a bad PIN.

Source

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

	var req shared.VerifyEmailPinRequest
	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)

	_, err = db.ValidateEmailVerification(req.Email, req.Pin)

	if err != nil {
		if err.Error() == db.InvalidOrExpiredPinError {
			http.Error(w, "Invalid or expired pin", http.StatusNotFound)
			return
		}

		log.Printf("Error validating email verification: %v\n", err)
		http.Error(w, "Error validating email verification: "+err.Error(), http.StatusInternalServerError)
		return
	}

	log.Println("Successfully verified email pin")
}

// sign in codes allow users to authenticate between different clients
// like UI to CLI or vice versa
func CreateSignInCodeHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for CreateSignInCodeHandler")

	auth := Authenticate(w, r, true)

	if auth == nil {
		return
	}

	// create pin - 6 alphanumeric characters

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the log for the wrapped error to see the actual DB failure
  2. Verify database health and connectivity (DATABASE_URL, pool limits)
  3. Run migrations to fix any schema drift
  4. Retry the request after the database recovers

Example fix

// before
_, err = db.ValidateEmailVerification(req.Email, req.Pin)
if err != nil {
	http.Error(w, "Error validating email verification: "+err.Error(), http.StatusInternalServerError)
}
// after: add a bounded retry for transient DB failures
var rec *shared.VerifyEmailPinResponse
for i := 0; i < 3; i++ {
	rec, err = db.ValidateEmailVerification(req.Email, req.Pin)
	if err == nil || err.Error() == db.InvalidOrExpiredPinError {
		break
	}
	time.Sleep(200 * time.Millisecond)
}
Defensive patterns

Strategy: retry

Validate before calling

// before the flow, confirm the backend is healthy
resp, err := http.Get(baseURL + "/health")
if err != nil || resp.StatusCode != 200 {
	return fmt.Errorf("backend unavailable, postpone pin verification: %v", err)
}

Try / catch

// distinguish expected invalid-pin from unexpected 500
if resp.StatusCode == http.StatusInternalServerError {
	var msg string
	json.NewDecoder(resp.Body).Decode(&msg)
	if strings.HasPrefix(msg, "Error validating email verification") {
		// transient DB failure: back off and retry
		time.Sleep(2 * time.Second)
		return retryVerify(email, pin)
	}
}

Prevention

When it happens

Trigger: POST to verify-email-pin where the underlying DB query inside db.ValidateEmailVerification errors: database unreachable, scan/row iteration failure, schema mismatch, or context/timeout cancellation.

Common situations: Postgres down or restarting during the request; migration drift making the query fail; connection pool exhausted under load; network partition between app and database in containerized deployments.

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