From 5b2ebdf53c6779fafbd2dc70278e1998d65b3ca2 Mon Sep 17 00:00:00 2001 From: Nick Ruest <127058086+nicholas-ruest@users.noreply.github.com> Date: Thu, 21 May 2026 21:10:55 +0000 Subject: [PATCH] fix: surface real API errors on registration; align seed script field name Registration form was swallowing the Cloud Function error and showing a generic "Registration failed" toast. When solo inventory hit 0, users (and operators) couldn't tell the form was actually reaching the service. - Register.tsx now parses ApiError and shows the server message - seed-inventory.sh: singleRemaining -> soloRemaining (matches what the deployed Cloud Function actually reads) Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/seed-inventory.sh | 6 +++--- src/pages/Register.tsx | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/seed-inventory.sh b/scripts/seed-inventory.sh index a9e850e..d6255ba 100755 --- a/scripts/seed-inventory.sh +++ b/scripts/seed-inventory.sh @@ -10,10 +10,10 @@ curl -s -X PATCH \ -H "Authorization: Bearer ${TOKEN}" \ -H "Content-Type: application/json" \ -H "x-goog-user-project: agenticsorg" \ - "https://firestore.googleapis.com/v1/projects/agenticsorg/databases/(default)/documents/retreat_config/inventory?updateMask.fieldPaths=singleRemaining&updateMask.fieldPaths=buddyRemaining&updateMask.fieldPaths=suiteRemaining" \ + "https://firestore.googleapis.com/v1/projects/agenticsorg/databases/(default)/documents/retreat_config/inventory?updateMask.fieldPaths=soloRemaining&updateMask.fieldPaths=buddyRemaining&updateMask.fieldPaths=suiteRemaining" \ -d '{ "fields": { - "singleRemaining": {"integerValue": "10"}, + "soloRemaining": {"integerValue": "10"}, "buddyRemaining": {"integerValue": "50"}, "suiteRemaining": {"integerValue": "20"} } @@ -24,7 +24,7 @@ if 'error' in d: print('ERROR:', d['error']) sys.exit(1) fields = d.get('fields', {}) -print('singleRemaining:', fields.get('singleRemaining', {}).get('integerValue')) +print('soloRemaining:', fields.get('soloRemaining', {}).get('integerValue')) print('buddyRemaining: ', fields.get('buddyRemaining', {}).get('integerValue')) print('suiteRemaining: ', fields.get('suiteRemaining', {}).get('integerValue')) print('Done.') diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index f9eccaa..6a8525f 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -16,7 +16,7 @@ import { SelectTrigger, SelectValue, } from "@shared/components/ui/select"; -import { submitInterest, createRegistrationSession } from "@/lib/api"; +import { submitInterest, createRegistrationSession, ApiError } from "@/lib/api"; // ── Early Interest ────────────────────────────────────────────────────────── const interestSchema = z.object({ @@ -136,8 +136,17 @@ function FullRegistrationForm() { }; const { url } = await createRegistrationSession(payload as Parameters[0]); window.location.href = url; - } catch { - toast.error("Registration failed. Please try again or contact retreat@agentics.org."); + } catch (err) { + let message = "Registration failed. Please try again or contact retreat@agentics.org."; + if (err instanceof ApiError) { + try { + const parsed = JSON.parse(err.message); + if (parsed?.error && typeof parsed.error === "string") message = parsed.error; + } catch { + if (err.message) message = err.message; + } + } + toast.error(message); } }