Skip to content

fix: waiting list duplicate check with a student or course that isn't saved yet - #1583

Merged
yuryyas merged 1 commit into
mainfrom
fix_waiting_list_duplicate_check_for_unsaved_student
Nov 16, 2026
Merged

yuryyas merged 1 commit into
mainfrom
fix_waiting_list_duplicate_check_for_unsaved_student

Conversation

@yuryyas

@yuryyas yuryyas commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

WaitingList.prePersist → validateDuplicate → WaitingListUtils.waitingListExists queries WaitingList by student and course. When the student or course is new in the same commit, Cayenne throws and the whole commit rolls back:

CayenneRuntimeException: Temporary id, probably an attempt to use NEW object as a query parameter.

Replication from willow hits this: a group with a new Student and their WaitingList fails, as reproduced by oncourse-secret InboundReplicationHandlerTest.testMainFlow (see ishgroup/oncourse-secret#125). Whether it happens in production depends on willow sending both in one group, which I haven't confirmed.

 waitingListExists(course, student, context, idToExclude)
+  if student or course is not saved yet
+    return false        // can't have a waiting list yet
   query WaitingList by student + course

Duplicate checks for saved students and courses are unchanged. This covers the API service caller and the prePersist / preUpdate callers.

Evidence

New WaitingListTest (integration):

  • Before: both tests fail with Temporary id, probably an attempt to use NEW object as a query parameter.
    After: both pass.
    • testCreateWithNewStudentAndCourse: a new course, student and waiting list commit together.
    • testDuplicateIsRejected: a second waiting list for the same saved student and course is still rejected with "already exists".
  • Related tests still pass: EnrolmentLifecycleListenerTest (3) and DataCollectionApiTest (8).

Merge Danger

Door: two-way

Blast Radius: small. Waiting list creation only. The one behaviour change: the duplicate check is skipped when the student or course is new, which can't match an existing waiting list.

After merge, the next 99-SNAPSHOT server-jar should turn testMainFlow green in oncourse-secret#125.

🤖 Generated with Claude Code

… saved yet

WaitingList.prePersist runs WaitingListUtils.waitingListExists, which
queried by student and course. When either is new in the same commit,
Cayenne throws "Temporary id, probably an attempt to use NEW object as a
query parameter". That rolls back replication groups from willow with a
new student and their waiting list (oncourse-secret
InboundReplicationHandlerTest.testMainFlow). A record that isn't saved
yet can't have a waiting list, so skip the query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Unit Test Results

  87 files    87 suites   4m 22s ⏱️
453 tests 443 ✔️ 10 💤 0 ❌
459 runs  449 ✔️ 10 💤 0 ❌

Results for commit 09e0276.

♻️ This comment has been updated with latest results.

@yuryyas
yuryyas merged commit 843912b into main Nov 16, 2026
5 checks passed
@yuryyas
yuryyas deleted the fix_waiting_list_duplicate_check_for_unsaved_student branch November 16, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant