From 990b862d41ff9ee95fd45cdbb80302286b12982b Mon Sep 17 00:00:00 2001 From: Shaun Hamilton Date: Sat, 17 May 2025 05:41:41 +0200 Subject: [PATCH] chore(api): log duplicate account ids (#60405) --- api/src/routes/helpers/auth-helpers.test.ts | 12 +++++++++--- api/src/routes/helpers/auth-helpers.ts | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/routes/helpers/auth-helpers.test.ts b/api/src/routes/helpers/auth-helpers.test.ts index a68f6f4d9c1..48173fa59f5 100644 --- a/api/src/routes/helpers/auth-helpers.test.ts +++ b/api/src/routes/helpers/auth-helpers.test.ts @@ -28,14 +28,20 @@ describe('findOrCreateUser', () => { }); it('should send a message to Sentry if there are multiple users with the same email', async () => { - await fastify.prisma.user.create({ data: createUserInput(email) }); - await fastify.prisma.user.create({ data: createUserInput(email) }); + const user1 = await fastify.prisma.user.create({ + data: createUserInput(email) + }); + const user2 = await fastify.prisma.user.create({ + data: createUserInput(email) + }); + + const ids = [user1.id, user2.id]; await findOrCreateUser(fastify, email); expect(captureException).toHaveBeenCalledTimes(1); expect(captureException).toHaveBeenCalledWith( - new Error('Multiple user records found for: test@user.com') + new Error(`Multiple user records found for: ${ids.join(', ')}`) ); }); diff --git a/api/src/routes/helpers/auth-helpers.ts b/api/src/routes/helpers/auth-helpers.ts index fead3840255..741bcb2998c 100644 --- a/api/src/routes/helpers/auth-helpers.ts +++ b/api/src/routes/helpers/auth-helpers.ts @@ -19,7 +19,9 @@ export const findOrCreateUser = async ( }); if (existingUser.length > 1) { fastify.Sentry.captureException( - new Error(`Multiple user records found for: ${email}`) + new Error( + `Multiple user records found for: ${existingUser.map(user => user.id).join(', ')}` + ) ); }