plandex-ai/plandex · error · http

Error creating email verification:

Error message

Error creating email verification: 

What it means

This error is returned by CreateEmailVerificationHandler when db.CreateEmailVerification fails to persist a new email verification record (email, user id, SHA-256-hashed 6-char PIN) in the database. The handler wraps the underlying DB error with the prefix 'Error creating email verification: ' and responds with HTTP 500. It means the server could not create the verification row, so the PIN it generated is unusable.

Source

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

	if !(os.Getenv("GOENV") == "development" && os.Getenv("LOCAL_MODE") == "1") {
		// create pin - 6 alphanumeric characters
		pinBytes, err := shared.GetRandomAlphanumeric(6)
		if err != nil {
			log.Printf("Error generating random pin: %v\n", err)
			http.Error(w, "Error generating random pin: "+err.Error(), http.StatusInternalServerError)
			return
		}

		// get sha256 hash of pin
		hashBytes := sha256.Sum256(pinBytes)
		pinHash := hex.EncodeToString(hashBytes[:])

		// create verification
		err = db.CreateEmailVerification(req.Email, req.UserId, pinHash)

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

		err = email.SendVerificationEmail(req.Email, string(pinBytes))

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

		res = shared.CreateEmailVerificationResponse{
			HasAccount: hasAccount,
		}
	} else {
		res = shared.CreateEmailVerificationResponse{
			HasAccount:  hasAccount,
			IsLocalMode: true,

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check the server log line for the wrapped underlying error to see the exact database failure
  2. Verify the database is reachable and DATABASE_URL/env config is correct
  3. Run pending migrations so the email_verifications table exists
  4. Check for unique/constraint conflicts (existing verification for the same email) and delete stale rows
  5. Retry the request once the database is healthy

Example fix

// before (app/server/handlers/sessions.go)
err = db.CreateEmailVerification(req.Email, req.UserId, pinHash)
if err != nil {
	http.Error(w, "Error creating email verification: "+err.Error(), http.StatusInternalServerError)
	return
}
// after (delete stale verification first so re-requests don't violate constraints)
if err := db.DeleteEmailVerification(req.Email); err != nil {
	log.Printf("Error clearing old verification: %v\n", err)
}
err = db.CreateEmailVerification(req.Email, req.UserId, pinHash)
if err != nil {
	log.Printf("Error creating email verification: %v\n", err)
	http.Error(w, "Error creating email verification: "+err.Error(), http.StatusInternalServerError)
	return
}
Defensive patterns

Strategy: retry

Validate before calling

// before calling the endpoint, ensure the service is reachable
resp, err := http.Get(baseURL + "/health")
if err != nil || resp.StatusCode != 200 {
	return fmt.Errorf("backend database likely unavailable: %v", err)
}

Try / catch

// Go client
resp, err := http.Post(url, "application/json", body)
if err != nil { return err }
if resp.StatusCode == http.StatusInternalServerError {
	// transient DB issue: back off and retry a limited number of times
	for i := 0; i < 3; i++ {
		time.Sleep(time.Duration(1<<i) * time.Second)
		// retry request...
	}
}

Prevention

When it happens

Trigger: POST to the email-verification endpoint with a valid body when the database insert in db.CreateEmailVerification fails: database unavailable, schema/constraint violation (e.g. duplicate email/user verification row), failed migration, or connection pool exhaustion.

Common situations: Postgres not running or misconfigured DATABASE_URL during local development; the email_verifications table missing because migrations did not run; unique constraint conflicts when requesting a verification repeatedly for the same email; disk-full or connection-limit issues in production.

Related errors


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