diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Endpoints/IdentityWebHooks/GetAnIdentityEndpoints.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Endpoints/IdentityWebHooks/GetAnIdentityEndpoints.cs index 1f9bde636..bb97b7c97 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Endpoints/IdentityWebHooks/GetAnIdentityEndpoints.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Endpoints/IdentityWebHooks/GetAnIdentityEndpoints.cs @@ -105,6 +105,11 @@ IDistributedLockProvider distributedLockProvider Contact.Fields.dfeta_LastIdentityUpdate }); + if (teacher is null) + { + throw new InvalidOperationException($"Received a webhook for a teacher that doesn't exist: {user.Trn}."); + } + if (notification.TimeUtc > (teacher.dfeta_LastIdentityUpdate ?? DateTime.MinValue)) { await dataverseAdapter.UpdateTeacherIdentityInfo(new UpdateTeacherIdentityInfoCommand()