-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed as not planned
Closed as not planned
Copy link
Labels
Medium priorityCreated by Linear-GitHub SyncCreated by Linear-GitHub Syncfoundation🐛 bugSomething isn't workingSomething isn't working
Description
The bug comes from here:
cal.com/packages/trpc/server/routers/viewer/teams/inviteMember/utils.ts
Lines 235 to 258 in d6927c5
| const usernameOrEmail = usernamesOrEmails[index]; | |
| const { orgId, autoAccept } = connectionInfoMap[usernameOrEmail]; | |
| const [emailUser, emailDomain] = usernameOrEmail.split("@"); | |
| const username = | |
| emailDomain === autoAcceptEmailDomain | |
| ? slugify(emailUser) | |
| : slugify(`${emailUser}-${emailDomain.split(".")[0]}`); | |
| const createdUser = await tx.user.create({ | |
| data: { | |
| username, | |
| email: usernameOrEmail, | |
| verified: true, | |
| invitedTo: input.teamId, | |
| organizationId: orgId || null, // If the user is invited to a child team, they are automatically added to the parent org | |
| teams: { | |
| create: { | |
| teamId: input.teamId, | |
| role: input.role as MembershipRole, | |
| accepted: autoAccept, // If the user is invited to a child team, they are automatically accepted | |
| }, | |
| }, | |
| }, | |
| }); |
This is causing a weird edge case where there might be the possibility that the generated user may exist already. causing a prisma error. Example: we have robert@example.com being converted to robert-example username. Which already exists in prod. On production this only returns a 500 error:
On dev we get this:
Object { message: "Invalid `prisma.user.create()` invocation: Unique constraint failed on the fields: (`username,`)", code: -32603, data: {…} }
Originally posted by @zomars in #11238 (comment)
From SyncLinear.com | CAL-3055
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Medium priorityCreated by Linear-GitHub SyncCreated by Linear-GitHub Syncfoundation🐛 bugSomething isn't workingSomething isn't working