fix(backend): check waitlist existence before update in update_waitlist_admin

Added find_unique check before update() call to properly return 404 when
waitlist doesn't exist, following the established pattern used in other
waitlist admin functions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Nicholas Tindle
2026-01-15 15:37:19 -06:00
parent 9c873a0158
commit 07ea2c2ab7

View File

@@ -2281,6 +2281,17 @@ async def update_waitlist_admin(
logger.info(f"Updating waitlist {waitlist_id}")
try:
# Check if waitlist exists first
existing = await prisma.models.WaitlistEntry.prisma().find_unique(
where={"id": waitlist_id}
)
if not existing:
raise ValueError(f"Waitlist {waitlist_id} not found")
if existing.isDeleted:
raise ValueError(f"Waitlist {waitlist_id} has been deleted")
# Build update data from explicitly provided fields
# Use model_fields_set to allow clearing fields by setting them to None
field_mappings = {
@@ -2312,9 +2323,6 @@ async def update_waitlist_admin(
include={"joinedUsers": True},
)
if not waitlist:
raise ValueError(f"Waitlist {waitlist_id} not found")
return _waitlist_to_admin_response(waitlist)
except ValueError:
raise