{"record":{"id":"56b936e72af74a90","repo":"plandex-ai/plandex","slug":"error-validating-email-verification","errorCode":null,"errorMessage":"Error validating email verification: ","messagePattern":"Error validating email verification: ","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"app/server/handlers/accounts.go","lineNumber":56,"sourceCode":"\n\tvar req shared.CreateAccountRequest\n\terr = json.Unmarshal(body, &req)\n\tif err != nil {\n\t\tlog.Printf(\"Error unmarshalling request: %v\\n\", err)\n\t\thttp.Error(w, \"Error unmarshalling request: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\treq.Email = strings.ToLower(req.Email)\n\n\tvar emailVerificationId string\n\n\t// skipping email verification in dev/local mode\n\tif !isLocalMode {\n\t\temailVerificationId, err = db.ValidateEmailVerification(req.Email, req.Pin)\n\n\t\tif err != nil {\n\t\t\tlog.Printf(\"Error validating email verification: %v\\n\", err)\n\t\t\thttp.Error(w, \"Error validating email verification: \"+err.Error(), http.StatusInternalServerError)\n\t\t\treturn\n\t\t}\n\t}\n\n\tvar apiErr *shared.ApiError\n\tvar user *db.User\n\tvar userId string\n\tvar token string\n\tvar orgId string\n\n\terr = db.WithTx(r.Context(), \"create account\", func(tx *sqlx.Tx) error {\n\t\tres, err := db.CreateAccount(req.UserName, req.Email, emailVerificationId, tx)\n\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error creating account: %v\", err)\n\t\t}\n\n\t\tuser = res.User","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/accounts.go#L38-L74","documentation":"Before creating the account, the handler calls db.ValidateEmailVerification(email, pin). If verification fails (unknown email, wrong/expired PIN, missing verification record), it responds 500 with `Error validating email verification: <detail>`. This is skipped in development local mode.","triggerScenarios":"POSTing a create-account request with a PIN that does not match the code emailed to the user, an email that never started verification, or a verification record that expired.","commonSituations":"Users mistyping the 4-6 digit PIN; waiting past the verification expiry window; requesting a new code and submitting the old one; running against a database missing the email_verification row.","solutions":["Re-request the verification email/PIN and submit the newest code","Double-check the email address matches the one verification was issued for","Verify the email_verification table has a row for this email and that it is unexpired","For local dev, set GOENV=development and LOCAL_MODE=1 to bypass verification"],"exampleFix":"// before\n{ \"email\": \"user@example.com\", \"pin\": \"123456\" }  // old/expired pin\n// after\nrequestNewVerificationPin(\"user@example.com\")\n// then submit the fresh pin","handlingStrategy":"validation","validationCode":"if email == \"\" || pin == \"\" {\n    return errors.New(\"email and verification pin are required\")\n}\n// ensure a verification was requested recently for this email","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Submit the newest PIN and re-request after expiry","Confirm email spelling matches the verification record","Use LOCAL_MODE=1 only in development"],"tags":["http","email-verification","database"],"backgroundTag":"email-verification-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}