Skip to content

Organization creation can 500 on a slug race instead of returning 409 #9

Description

@presidojay1

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').

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions