refactor: reserved slot and booking intercation#24670
Draft
refactor: reserved slot and booking intercation#24670
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
5 issues found across 29 files
Prompt for AI agents (all 5 issues)
Understand the root cause of the following 5 issues and fix them.
<file name="packages/features/bookings/lib/service/InstantBookingCreateService.ts">
<violation number="1" location="packages/features/bookings/lib/service/InstantBookingCreateService.ts:171">
Rule violated: **Avoid Logging Sensitive Information**
This debug log prints the entire bookingMeta object, which per CreateBookingMeta includes sensitive identifiers (e.g., userId, reservedSlotUid). Logging this data violates our “Avoid Logging Sensitive Information” policy. Please remove the console statement.</violation>
</file>
<file name="docs/api-reference/v2/openapi.json">
<violation number="1" location="docs/api-reference/v2/openapi.json:25457">
The reservedSlotUid description is truncated, ending without the object it refers to. Please complete the sentence so the API docs clearly describe how the value is used.</violation>
</file>
<file name="packages/features/bookings/lib/service/RecurringBookingService.ts">
<violation number="1" location="packages/features/bookings/lib/service/RecurringBookingService.ts:107">
Setting `reservedSlotUid` to `undefined` here drops the reserved slot on the first (non-round-robin) booking, so the reserved slot cookie is never honored for recurring bookings that aren’t round robin. Use the passed-in UID when `key === 0` so the initial booking respects the reservation.</violation>
</file>
<file name="apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts">
<violation number="1" location="apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts:128">
Adding reservedSlotUid to the body alone leaves bookingRequest.reservedSlotUid undefined, so bookings.service ignores the reservation. Please also assign reservedSlotUid on the request object before returning.</violation>
</file>
<file name="packages/features/bookings/lib/handleNewBooking/createBookingWithReservedSlot.ts">
<violation number="1" location="packages/features/bookings/lib/handleNewBooking/createBookingWithReservedSlot.ts:25">
`dayjs(...).utc().format()` drops fractional seconds, so the Date you build loses millisecond precision. When the selected slot was saved with non-zero milliseconds (ISO strings from `Date.toISOString()` include them), the equality filter in `deleteMany` won’t match and the reserved slot record survives, blocking new reservations. Please preserve the original precision (e.g. use `.valueOf()` / `.toDate()` instead of `.format()` on both start and end conversions).</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
packages/features/bookings/lib/service/InstantBookingCreateService.ts
Outdated
Show resolved
Hide resolved
packages/features/bookings/lib/service/RecurringBookingService.ts
Outdated
Show resolved
Hide resolved
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts
Outdated
Show resolved
Hide resolved
packages/features/bookings/lib/handleNewBooking/createBookingWithReservedSlot.ts
Outdated
Show resolved
Hide resolved
Contributor
E2E results are ready! |
supalarry
commented
Dec 15, 2025
packages/features/bookings/lib/service/RegularBookingService.ts
Outdated
Show resolved
Hide resolved
Comment on lines
+2796
to
+2823
| const eventType = await getEventType({ | ||
| eventTypeId: input.bookingData.eventTypeId, | ||
| eventTypeSlug: input.bookingData.eventTypeSlug, | ||
| }); | ||
|
|
||
| // note(Lauris): I know this function is called createBooking but it is called by web booker when rescheduling | ||
| await validateRescheduleRestrictions({ | ||
| rescheduleUid: input.bookingData.rescheduleUid, | ||
| userId: input.bookingMeta?.userId ?? null, | ||
| eventType: eventType | ||
| ? { | ||
| seatsPerTimeSlot: eventType.seatsPerTimeSlot, | ||
| minimumRescheduleNotice: eventType.minimumRescheduleNotice ?? null, | ||
| } | ||
| : null, | ||
| }); | ||
|
|
||
| const reservedSlot = this.getReservedSlotIfNotTeamOrSeatedEvent(input, eventType); | ||
| if (reservedSlot) { | ||
| await this.checkReservedSlotIsEarliest(reservedSlot); | ||
| } | ||
|
|
||
| const res = await handler({ bookingData: input.bookingData, ...input.bookingMeta }, this.deps, eventType); | ||
|
|
||
| if (reservedSlot) { | ||
| await this.deleteReservedSlot(reservedSlot); | ||
| } | ||
| return res; |
Contributor
There was a problem hiding this comment.
looks great, aligned with our refactor initiative to make code more semantic
Contributor
Devin AI is resolving merge conflictsThis PR has merge conflicts with the Devin will:
If you prefer to resolve conflicts manually, you can close the Devin session and handle it yourself. |
Contributor
|
converting this to a draft. let us know when this is ready for review again. |
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.
See Linear ticket for walkthrough CAL-6430
Fixes #23938
Summary by cubic
Adds reserved-slot validation to booking to prevent double bookings. Passes reservedSlotUid end-to-end, checks the earliest active reservation, consumes it on booking, and centralizes cookie/body extraction.
New Features
Refactors
Written for commit e600891. Summary will update automatically on new commits.