chore: [Booking Cancellation Refactor - 2] Inject repositories and use them instead of Prisma in cancellation flow#3
Open
tomerqodo wants to merge 2 commits into
Open
chore: [Booking Cancellation Refactor - 2] Inject repositories and use them instead of Prisma in cancellation flow#3tomerqodo wants to merge 2 commits into
tomerqodo wants to merge 2 commits into
Conversation
Comment on lines
+513
to
518
| const allUpdatedBookings = await bookingRepository.findManyIncludeWorkflowRemindersAndReferences({ | ||
| where: { | ||
| recurringEventId: bookingToDelete.recurringEventId, | ||
| startTime: { | ||
| gte: new Date(), | ||
| }, | ||
| }, | ||
| select: { | ||
| id: true, | ||
| startTime: true, | ||
| endTime: true, | ||
| references: { | ||
| select: { | ||
| uid: true, | ||
| type: true, | ||
| externalCalendarId: true, | ||
| credentialId: true, | ||
| }, | ||
| gte: bookingToDelete.startTime, | ||
| }, |
There was a problem hiding this comment.
Bug: When cancelling subsequent recurring bookings, the findMany query for reminder cleanup uses a different gte time filter than the updateMany query that performs the cancellation.
Severity: MEDIUM
Suggested Fix
The findMany operation should use the same gte variable that was calculated for and used by the updateMany operation. This ensures that reminder cleanup is performed on the exact same set of bookings that were cancelled.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/features/bookings/lib/handleCancelBooking.ts#L513-L518
Potential issue: When cancelling subsequent recurring bookings where
`cancelSubsequentBookings` is true, the logic to cancel bookings and the logic to clean
up their reminders use different time filters. The cancellation query (`updateMany`)
uses `startTime: { gte: new Date() }`, while the subsequent query to find bookings for
reminder deletion (`findMany`) uses `startTime: { gte: bookingToDelete.startTime }`.
This mismatch can cause workflow reminders to be deleted for bookings that were not
actually cancelled, specifically when cancelling a booking that has already started but
not yet ended.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark PR from agentic-review-benchmarks#3