Skip to content

fix: auth/sync creates user on first login, fix 500 on profile update#16

Merged
bryanfawcett merged 2 commits intomainfrom
fix/schema-db-alignment-db-layer
Mar 24, 2026
Merged

fix: auth/sync creates user on first login, fix 500 on profile update#16
bryanfawcett merged 2 commits intomainfrom
fix/schema-db-alignment-db-layer

Conversation

@bryanfawcett
Copy link
Copy Markdown
Contributor

Summary

  • auth/sync now creates the user DB record immediately on first login instead of returning a stub. This was causing a 500 on PATCH /api/auth/profile because the INSERT tried to use an empty email string, hitting the UNIQUE NOT NULL constraint.
  • PATCH /api/auth/profile now only does UPDATE (no INSERT fallback) — if no user is found it returns a clear 404 instead of a silent 500.
  • Reverts STYTCH_PROJECT_ID to the correct project-live-86090362-... value (previous fix incorrectly derived the project ID from the public token UUID, which are separate identifiers in Stytch).
  • Adds [nhimbe] console error logging to auth flows so JWT failures are visible in browser DevTools.
  • Fixes location-prompt sending address_locality/address_country instead of city/country that the backend reads.

Test plan

  • Worker type check passes
  • Sign in via Stytch → auth/sync creates user row → no 500
  • Enter name in name prompt → PATCH /api/auth/profile updates the row → no 500
  • events-api.mukoko.com deployed with all fixes

🤖 Generated with Claude Code

New users were getting a 500 on PATCH /api/auth/profile because auth/sync
returned a stub without creating a DB record, then the profile endpoint
tried to INSERT with empty email hitting the UNIQUE NOT NULL constraint.

Fix: auth/sync now always creates the user row on first login so the
profile PATCH only needs to UPDATE (never INSERT).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Mar 24, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
mukoko-nhimbe-api 4ceb486 Mar 24 2026, 07:33 AM

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nhimbe Ready Ready Preview, Comment Mar 24, 2026 7:33am

Request Review

…rofile test

- Fix prefer-const lint error in auth.ts (userId is never reassigned)
- Update auth-profile test to expect 404 when user not found (INSERT removed,
  user must exist via auth/sync before profile PATCH)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bryanfawcett bryanfawcett merged commit 504ce6c into main Mar 24, 2026
16 checks passed
@bryanfawcett bryanfawcett deleted the fix/schema-db-alignment-db-layer branch March 24, 2026 07:35
bryanfawcett pushed a commit that referenced this pull request Apr 9, 2026
#16: FilterBar scroll affordance - edge fade gradients that appear
     when content overflows left/right (ResizeObserver + scroll listener)
#17: Search result images use lazy loading (img loading="lazy" instead
     of inline background-url CSS)
#32: FAQ open state persisted to localStorage, restored on page load
#35: Signage auto-refresh pause/resume toggle button (pause/play icons)
#36: Calendar month/year quick-select dropdowns replace plain heading
#37: Admin pagination page number buttons (up to 5 visible pages with
     sliding window) for both events and users tables
#38: Admin sidebar shows all nav items - inaccessible ones greyed out
     with lock icon and "Requires X role" tooltip instead of hidden
#39: Cmd+K / Ctrl+K keyboard shortcut navigates to /search from anywhere

https://claude.ai/code/session_01GBDmHPeMz4FCeN4fn5Ujnx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant