fix: Handle deleted user or team in UserCreatedProcessor (#12839)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom MoorandClaude Opus 4.8 authored and GitHub committed 2026-06-25 20:49:02 -04:00
1 parent 54be0a9db3
commit e237e6df47
1 file changed
+7 -2
@@ -11,10 +11,15 @@ export default class UserCreatedProcessor extends BaseProcessor {
async perform(event: UserEvent) {
const [user, team] = await Promise.all([
User.findByPk(event.userId, { rejectOnEmpty: true }),
Team.findByPk(event.teamId, { rejectOnEmpty: true }),
User.findByPk(event.userId),
Team.findByPk(event.teamId),
]);
// The user or team may have been deleted before this event is processed.
if (!user || !team) {
return;
}
// Invited users receive an InviteEmail at invite time, and a WelcomeEmail
// when they accept the invite and sign in for the first time.
if (event.name === "users.create" && user.isInvited) {