Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signup): surface email validation errors at the email step in paper-desk flow (#66318)

Fernando Gomeseb9032c132f0
diff --git a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
index f15a1caf9dec..4d58fe6190a9 100644
--- a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
+++ b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
@@ -6,6 +6,58 @@ import { initKeaTests } from '~/test/init'
import { signupLogic } from './signupLogic'
+describe('signupLogic — email error surfacing', () => {
+ let logic: ReturnType<typeof signupLogic.build>
+
+ beforeEach(() => {
+ useMocks({
+ post: {
+ '/api/signup/precheck': () => [200, { email_exists: false, pending_invite: null }],
+ '/api/signup/': () => [400, { email: ['There is already an account with this email address.'] }],
+ },
+ })
+ initKeaTests()
+ router.actions.push('/signup')
+ logic = signupLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ it('redirects to the email panel and shows the error when the final POST fails with an email error', async () => {
+ // Advance through email panel (precheck passes)
+ logic.actions.setSignupPanelEmailValue('email', '[email protected]')
+ logic.actions.submitSignupPanelEmail()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.panel).toBe(1)
+
+ // Advance through auth panel (a valid password is required to pass form validation)
+ logic.actions.setSignupPanelAuthValue('password', 'Str0ng-Test-Pass!')
+ logic.actions.submitSignupPanelAuth()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.panel).toBe(2)
+
+ // Submit onboarding — final POST fails with an email error
+ logic.actions.setSignupPanelOnboardingValues({
+ name: 'Jane Doe',
+ organization_name: 'Hogflix',
+ role_at_organization: 'engineer',
+ referral_source: '',
+ referral_source_ai_prompt: '',
+ })
+ logic.actions.submitSignupPanelOnboarding()
+ await expectLogic(logic).toFinishAllListeners()
+
+ // User should be sent back to step 0 with the email error shown there
+ expect(logic.values.panel).toBe(0)
+ expect(logic.values.signupPanelEmailManualErrors.email).toBe(
+ 'There is already an account with this email address.'
+ )
+ })
+})
+
describe('signupLogic — pending invite banner', () => {
let logic: ReturnType<typeof signupLogic.build>
diff --git a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
index b7017931eef2..dab83576fcff 100644
--- a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
+++ b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
@@ -209,8 +209,14 @@ export const signupLogic = kea<signupLogicType>([
actions.setPanel(0)
return
}
+ const fieldError = e?.data?.email
+ const emailErrorMessage = fieldError
+ ? Array.isArray(fieldError)
+ ? String(fieldError[0])
+ : String(fieldError)
+ : e?.detail || 'Could not verify your email. Please try again.'
actions.setSignupPanelEmailManualErrors({
- email: e?.detail || 'Could not verify your email. Please try again.',
+ email: emailErrorMessage,
})
return
}
@@ -309,6 +315,16 @@ export const signupLogic = kea<signupLogicType>([
actions.resetChallenge()
+ // If the server returns an email validation error, send the user back to the
+ // email step so the error appears next to the field that caused it.
+ const emailError = error.data?.email
+ if (emailError) {
+ const message = Array.isArray(emailError) ? String(emailError[0]) : String(emailError)
+ actions.setSignupPanelEmailManualErrors({ email: message })
+ actions.setPanel(0)
+ return
+ }
+
if (error.code === 'throttled') {
actions.setSignupPanelOnboardingManualErrors({
generic: {
@@ -364,8 +380,14 @@ export const signupLogic = kea<signupLogicType>([
actions.setPanel(0)
return
}
+ const fieldError = e?.data?.email
+ const emailErrorMessage = fieldError
+ ? Array.isArray(fieldError)
+ ? String(fieldError[0])
+ : String(fieldError)
+ : e?.detail || 'Could not verify your email. Please try again.'
actions.setSignupPanel1ManualErrors({
- email: e?.detail || 'Could not verify your email. Please try again.',
+ email: emailErrorMessage,
})
return
}
@@ -440,6 +462,14 @@ export const signupLogic = kea<signupLogicType>([
actions.resetChallenge()
+ const emailError = error.data?.email
+ if (emailError) {
+ const message = Array.isArray(emailError) ? String(emailError[0]) : String(emailError)
+ actions.setSignupPanel1ManualErrors({ email: message })
+ actions.setPanel(0)
+ return
+ }
+
if (error.code === 'throttled') {
actions.setSignupPanel2ManualErrors({
generic: {