create() checks slug uniqueness with findUnique and then creates the org inside a $transaction, with no error handling for the create call. Two concurrent requests for the same slug will cause the second tx.organization.create() to throw an uncaught P2002 Prisma error, surfacing as a 500 instead of a proper ConflictException.
Suggested fix: Catch the Prisma unique-constraint error (code P2002) around the transaction and rethrow as ConflictException('That organization slug is already taken').
create()checks slug uniqueness withfindUniqueand then creates the org inside a$transaction, with no error handling for the create call. Two concurrent requests for the same slug will cause the secondtx.organization.create()to throw an uncaughtP2002Prisma error, surfacing as a 500 instead of a properConflictException.Suggested fix: Catch the Prisma unique-constraint error (code
P2002) around the transaction and rethrow asConflictException('That organization slug is already taken').