Code Review Bench PR #26523 - chore: Integrate confirmation booking audit#10
Code Review Bench PR #26523 - chore: Integrate confirmation booking audit#10ketkarameya wants to merge 2 commits intobase_pr_26523_20260125_3542from
Conversation
| }, | ||
| }); | ||
| updatedBookings.push(updatedBooking); | ||
| acceptedBookings = [ |
There was a problem hiding this comment.
⚠️ Bug: Non-recurring accepted booking audit logs ACCEPTED as oldStatus
In the non-recurring booking acceptance path in handleConfirmation.ts, oldStatus is hardcoded to BookingStatus.ACCEPTED (line 413). This is incorrect — handleConfirmation is called to confirm a booking, meaning the booking's prior status is typically PENDING (for bookings requiring confirmation). The booking.status field is available in scope and should be used instead.
This causes the audit log to record a status transition of ACCEPTED → ACCEPTED, which is meaningless and defeats the purpose of the status tracking in audit logs.
The recurring path correctly captures oldStatus from unconfirmedRecurringBookings before the update, so the fix is straightforward.
Was this helpful? React with 👍 / 👎
| acceptedBookings = [ | |
| acceptedBookings = [ | |
| { | |
| oldStatus: booking.status, | |
| uid: booking.uid, | |
| }, | |
| ]; |
- Apply suggested fix
| }, | ||
| }); | ||
|
|
||
| const updatedRecurringBookings = await prisma.booking.findMany({ |
There was a problem hiding this comment.
⚠️ Bug: Recurring rejection reads post-update status as oldStatus
In confirm.handler.ts, the recurring booking rejection path first calls updateMany to set status to REJECTED (line 420-430), then queries the database to get the "fresh" status (line 432-442), and uses that as oldStatus (line 444-446).
Since the query runs after the update, recurringBooking.status will be REJECTED — the new status, not the old one. This means the audit log records a transition of REJECTED → REJECTED, which is wrong. It should record PENDING → REJECTED.
The PR description mentions the intent was to "query database immediately after status updates to get fresh values for audit logging," but for oldStatus the pre-update value is what's needed. The unconfirmedRecurringBookings query (line 409-418) already captures the pre-update status (which should be PENDING). Use that instead.
Suggested approach: map oldStatus from unconfirmedRecurringBookings instead of updatedRecurringBookings.
Was this helpful? React with 👍 / 👎
| const updatedRecurringBookings = await prisma.booking.findMany({ | |
| rejectedBookings = unconfirmedRecurringBookings.map((recurringBooking) => ({ | |
| uid: recurringBooking.uid, | |
| oldStatus: recurringBooking.status, | |
| })); |
- Apply suggested fix
There was a problem hiding this comment.
Configure merge blocking · Maintainers can dismiss this review. Gitar never approves changes.
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
Benchmark Evaluation ResultsGround Truth Bugs (Recall: 2/4 = 50.0%)
Extra Gitar Findings
Summary
|
Benchmark PR for Gitar evaluation
Original PR: agentic-review-benchmarks#10
chore: Integrate confirmation booking audit
Summary by Gitar
Fixed duplicate booking acceptance events: Recurring booking confirmations triggered
fireBookingAcceptedEventtwice (once in recurring block, once at handler end). Now fires early in recurring block with conditionalif (!recurringEventId)check at handler end to prevent duplicates.Added organization context resolution: Audit events for recurring bookings lacked org/team scope. Now resolves
teamIdviagetTeamIdFromEventType, determines user-level vs org-level firing based on team existence and parent relationships, and includesorganizationIdin event payload.Corrected audit log status accuracy: Audit logs recorded stale pre-update status values. Now queries database immediately after
updateManycalls (e.g., for rejections) to capture actual persistedREJECTEDstatus instead of in-memory stale data.Implemented multi-tenant event scoping: Events fire at user-level when no team exists or for sub-teams (
parentIdpresent), and at org-level for top-level teams. UsesgetOrgIdFromMemberOrTeamIdto resolve organization context.This will update automatically on new commits.