Skip to content

fix(ts): rename User.username → User.name (schema drift)#18

Open
abdout wants to merge 1 commit into
mainfrom
fix/ts-username-rename
Open

fix(ts): rename User.username → User.name (schema drift)#18
abdout wants to merge 1 commit into
mainfrom
fix/ts-username-rename

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented Apr 25, 2026

Summary

  • Schema is canonical: `User.name` exists, `User.username` does not. 7 call sites referenced the removed field, silently masked by `ignoreBuildErrors`.
  • Real bug uncovered: `src/auth.ts:122` did `token.name = existingUser.username` — this evaluates to `undefined` at runtime, so every JWT shipped `name: undefined`. Every signed-in user has had `session.user.name === undefined` until this lands. After merge, header avatars / dropdowns / modals that display `user.name` will populate correctly.
  • Mechanical rename, no schema migration needed.

Changes

  • `src/auth.ts` — JWT enrichment fix
  • `src/components/marketing/pricing/forms/user-name.action.ts`
  • `src/components/marketing/pricing/actions/update-user-name.ts`
  • `src/components/marketing/pricing/lib/user.ts`
  • `src/components/marketing/pricing/lib/email.ts`
  • `src/components/marketing/pricing/shared/user-avatar.tsx`
  • `src/components/marketing/pricing/modals/delete-account-modal.tsx` (UserAvatar caller — cascade)

Test plan

  • Sign in → header avatar shows the user's name (was previously empty/email-fallback)
  • Settings → "Your Name" form persists to DB and re-renders updated name
  • `pnpm tsc --noEmit` → 7 fewer errors (36 → 29 verified locally)
  • Magic-link email path still types-correctly (firstName uses `user.name`)

Follow-ups

  • Class 1 dead imports remain (12 errors — `@/components/platform/`, `@/components/onboarding/`, `@/components/invoice/*`, `@/components/atom/modal`, `@react-email/components`, `db.subscriptionTier`) — needs your decision per feature
  • Class 5 `LayoutProps` (1 error) — pending after fix(auth): restore SessionProvider in [lang]/layout #10 merges

Closes #17

🤖 Generated with Claude Code

The Prisma schema defines User.name (no username field). Seven call
sites still referenced the removed username, masked by
typescript.ignoreBuildErrors.

The real bug: src/auth.ts:122 set token.name = existingUser.username,
which is undefined at runtime, so every JWT token shipped a
name=undefined. session.user.name has been undefined for every signed-in
user.

Files renamed or updated:
- src/auth.ts (JWT enrichment — actual bug fix)
- src/components/marketing/pricing/forms/user-name.action.ts
- src/components/marketing/pricing/actions/update-user-name.ts
- src/components/marketing/pricing/lib/user.ts
- src/components/marketing/pricing/lib/email.ts
- src/components/marketing/pricing/shared/user-avatar.tsx
- src/components/marketing/pricing/modals/delete-account-modal.tsx
  (cascade — UserAvatar caller updated)

Skipped: lib/get-tier-id.ts (db.subscriptionTier — separate Class 1
schema issue, deferred).

Closes #17

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

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

Project Deployment Actions Updated (UTC)
marketing Ready Ready Preview, Comment Apr 25, 2026 9:50am

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.

fix(ts): rename User.username refs to User.name (schema drift, Class 2)

1 participant