From 1a2043eaaeb5dd3dc084b984d3a62ce7523094e8 Mon Sep 17 00:00:00 2001 From: tanweer919 Date: Mon, 13 Jul 2026 20:44:05 +0530 Subject: [PATCH] fix(login): readable email-OTP send error instead of raw '{}' gotrue can throw an error whose message is an unhelpful JSON blob (e.g. 500 'Error sending magic link email' when Supabase SMTP isn't configured). Show a readable, actionable message instead of rendering the raw payload. --- src/components/portal/login-flow.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/portal/login-flow.tsx b/src/components/portal/login-flow.tsx index d037880..8c23119 100644 --- a/src/components/portal/login-flow.tsx +++ b/src/components/portal/login-flow.tsx @@ -454,7 +454,14 @@ function OtpVerify({ account, email, initialChannel = "email", remember, setReme if (!PHONE_RE.test(phone)) { setError("Enter your phone in international format, e.g. +14155550100."); return; } await sendPhoneOtp(phone); setSent(true); } - } catch (e) { setError((e as Error).message); } + } catch (e) { + // gotrue can throw an error whose message is an unhelpful "{}"/JSON blob (e.g. a + // 500 "Error sending magic link email" when SMTP isn't set up). Show something + // readable and actionable instead of the raw payload. + const raw = (e as { message?: unknown })?.message; + const readable = typeof raw === "string" && raw.trim() && !raw.trim().startsWith("{") ? raw.trim() : ""; + setError(readable || "We couldn't send your sign-in code right now. Please try again shortly, or sign in with your password."); + } } async function complete(code: string) { -- 2.52.0