Bug
Creating a lobby sometimes throws a 500 error instead of retrying with a new code:
Invalid `prisma.lobbies.create()` invocation
Unique constraint failed on the fields: (`code`)
Root Cause
isLobbyCodeConflict() in app/api/lobby/route.ts checks meta.target to confirm the P2002 is for the code field. In Prisma 7, meta.target can be null/undefined even on a genuine code collision, causing the function to return false and the API to throw instead of retry.
Fix
Add fallback: when prismaCode === 'P2002' and target is absent, check the error message string for "unique constraint"" + "code"; if that also fails, return true (any P2002 on lobbies.create must be the code field).
Bug
Creating a lobby sometimes throws a 500 error instead of retrying with a new code:
Root Cause
isLobbyCodeConflict()inapp/api/lobby/route.tschecksmeta.targetto confirm the P2002 is for thecodefield. In Prisma 7,meta.targetcan benull/undefinedeven on a genuine code collision, causing the function to returnfalseand the API to throw instead of retry.Fix
Add fallback: when
prismaCode === 'P2002'andtargetis absent, check the error message string for"unique constraint"" + "code"; if that also fails, returntrue(any P2002 onlobbies.createmust be the code field).