chore(api): log duplicate account ids (#60405)

This commit is contained in:
Shaun Hamilton
2025-05-17 05:41:41 +02:00
committed by GitHub
parent 49c28fcb42
commit 990b862d41
2 changed files with 12 additions and 4 deletions
+9 -3
View File
@@ -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(', ')}`)
);
});
+3 -1
View File
@@ -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(', ')}`
)
);
}