Skip to content

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 29, 2026

Benchmark PR from agentic-review-benchmarks#11

Summary by CodeRabbit

  • New Features

    • Enhanced booking cancellation webhooks to include event details (title, length, iCal sequence) and a reschedule request indicator.
    • Introduced configuration control to enable or disable webhook delivery.
  • Documentation

    • Updated webhook payload documentation with new fields and example structures.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 29, 2026

Walkthrough

This pull request extends webhook payloads for booking cancellations with additional metadata fields (eventTypeId, title, length, iCalSequence) and introduces a requestReschedule flag throughout the webhook infrastructure. It also adds a feature flag to conditionally control webhook dispatch in booking cancellation logic.

Changes

Cohort / File(s) Summary
Documentation
docs/developing/guides/automation/webhooks.mdx
Updated BOOKING_CANCELLED webhook example to include requestReschedule: false field in payload.
Webhook Types & DTOs
packages/features/webhooks/lib/dto/types.ts, packages/features/webhooks/lib/sendPayload.ts, packages/features/webhooks/lib/types/params.ts
Extended BookingCancelledDTO, EventPayloadType, and BookingCancelledParams with optional requestReschedule?: boolean and iCalSequence?: number | null fields.
Webhook Payload Building
packages/features/webhooks/lib/factory/base/BaseBookingPayloadBuilder.ts, packages/features/webhooks/lib/factory/versioned/v2021-10-20/BookingPayloadBuilder.ts
Updated BookingExtraDataMap for BOOKING_CANCELLED event to include optional requestReschedule field; added default value handling in v2021-10-20 builder.
Webhook Service
packages/features/webhooks/lib/service/BookingWebhookService.ts
Added requestReschedule field to BookingCancelledDTO payload in emitBookingCancelled method.
Booking Cancellation Logic
packages/features/bookings/lib/handleCancelBooking.ts, packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts
Added ENABLE_WEBHOOKS feature flag to conditionally dispatch webhooks; included requestReschedule field in cancellation payloads.
Booking Repository
packages/features/bookings/repositories/BookingRepository.ts
Expanded findByUidIncludeEventTypeAndReferences query to select additional eventType fields (title, length) and top-level booking field (iCalSequence).
Webhook Factory
packages/lib/server/service/BookingWebhookFactory.ts, packages/lib/server/service/__tests__/BookingWebhookFactory.test.ts
Extended CancelledEventPayload interface with eventTypeId, length, iCalSequence, eventTitle, and requestReschedule; updated factory method and tests to populate these fields.
Reschedule Handler
packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts
Enhanced reschedule payloads with additional event metadata (eventTypeId, length, iCalSequence, eventTitle) and set requestReschedule: true flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Webhooks now whisper more secrets to share,
EventType metadata floats through the air,
With iCalSequence ticked and reschedule in sight,
Our payloads grow richer, more context-aware and bright!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: making the BOOKING_CANCELLED webhook payload consistent across regular cancellation and request-reschedule flows, which is reflected throughout the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts (1)

162-168: Hardcoded requestReschedule: true appears incorrect for a generic seat cancellation.

Cancelling an attendee seat is not inherently a reschedule request. The webhook documentation shows requestReschedule: false for regular cancellations. This should be false by default, or ideally passed as a parameter from the caller to distinguish actual reschedule-triggered cancellations from regular ones.

🐛 Proposed fix
 const payload: EventPayloadType = {
   ...evt,
   ...eventTypeInfo,
   status: "CANCELLED",
   smsReminderNumber: bookingToDelete.smsReminderNumber || undefined,
-  requestReschedule: true,
+  requestReschedule: false,
 };

Alternatively, if this function can be called from reschedule flows, consider adding a parameter to control this value.

🤖 Fix all issues with AI agents
In
`@packages/features/webhooks/lib/factory/versioned/v2021-10-20/BookingPayloadBuilder.ts`:
- Around line 45-50: In BookingPayloadBuilder, the extra.requestReschedule
default is incorrect; change the logic that sets extra.requestReschedule
(currently dto.requestReschedule ?? true) so it defaults to false when
dto.requestReschedule is undefined, i.e. use dto.requestReschedule ?? false (or
equivalent) so only explicit reschedule cancellations set it true; update the
assignment in the block that constructs extra (fields cancelledBy,
cancellationReason, requestReschedule) to reflect this.
🧹 Nitpick comments (1)
packages/features/bookings/lib/handleCancelBooking.ts (1)

413-430: Make the webhook feature flag parsing more robust.
Line 413-415: ENABLE_WEBHOOKS !== "false" treats "FALSE"/"0" as enabled. Consider normalizing to avoid surprising behavior in different env setups.

♻️ Suggested tweak
-  const webhooksEnabled = process.env.ENABLE_WEBHOOKS !== "false";
+  const webhooksEnabled = !["false", "0", "no"].includes(
+    (process.env.ENABLE_WEBHOOKS ?? "").toLowerCase()
+  );
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf1d5da and f1abf5d.

📒 Files selected for processing (13)
  • docs/developing/guides/automation/webhooks.mdx
  • packages/features/bookings/lib/handleCancelBooking.ts
  • packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts
  • packages/features/bookings/repositories/BookingRepository.ts
  • packages/features/webhooks/lib/dto/types.ts
  • packages/features/webhooks/lib/factory/base/BaseBookingPayloadBuilder.ts
  • packages/features/webhooks/lib/factory/versioned/v2021-10-20/BookingPayloadBuilder.ts
  • packages/features/webhooks/lib/sendPayload.ts
  • packages/features/webhooks/lib/service/BookingWebhookService.ts
  • packages/features/webhooks/lib/types/params.ts
  • packages/lib/server/service/BookingWebhookFactory.ts
  • packages/lib/server/service/__tests__/BookingWebhookFactory.test.ts
  • packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/features/bookings/lib/handleCancelBooking.ts (2)
packages/features/booking-audit/lib/makeActor.ts (2)
  • buildActorEmail (84-86)
  • getUniqueIdentifier (88-90)
packages/features/webhooks/lib/WebhookService.ts (1)
  • sendPayload (21-37)
🔇 Additional comments (22)
packages/features/bookings/repositories/BookingRepository.ts (5)

142-179: Looks good: conditional filters remain precise.

The rrTimestampBasis switch and virtual queue filters keep the query scoped correctly.


328-328: LGTM (constructor change).


659-672: LGTM: pending bookings query is well scoped.


1659-1664: Good addition: richer eventType and iCal fields.

Also applies to: 1687-1689


1919-1925: LGTM (recorded status updater).

docs/developing/guides/automation/webhooks.mdx (1)

314-315: LGTM!

The documentation correctly shows requestReschedule: false for a regular booking cancellation example, which aligns with the semantic meaning of the field.

packages/features/webhooks/lib/dto/types.ts (2)

42-58: LGTM!

The DTO extensions for iCalSequence and requestReschedule are well-typed and appropriately optional, supporting the new webhook payload fields.


571-588: LGTM!

The requestReschedule field addition to EventPayloadType aligns with the broader payload consistency changes.

packages/features/webhooks/lib/types/params.ts (1)

40-66: LGTM!

The parameter type extensions for iCalSequence and requestReschedule are consistent with the DTO definitions and enable proper propagation through the cancellation flow.

packages/lib/server/service/__tests__/BookingWebhookFactory.test.ts (1)

88-116: LGTM!

The test correctly validates the expanded payload structure, including the new eventTitle, eventTypeId, length, requestReschedule, iCalSequence, and status fields. This provides good coverage for the payload contract.

packages/features/webhooks/lib/sendPayload.ts (1)

95-100: Propagate requestReschedule in the base event payload type.
Line 99: This is the right place to surface the new flag so downstream payload builders stay consistent.

packages/features/bookings/lib/handleCancelBooking.ts (5)

57-62: Audit actor helpers import is appropriate.
Line 57-62: Centralizing email/identifier generation for audit actors keeps the attribution logic consistent.


110-120: Guest actor email generation looks sound.
Line 110-120: Using a generated identifier avoids trusting user-supplied emails for audit attribution.


154-160: Good guardrail for missing action source.
Line 154-160: Logging UNKNOWN actionSource helps track callers that skip metadata.


374-379: Team payload block is consistent.
Line 374-379: Team metadata is still conditionally attached only for team events.


734-734: Constructor addition is fine.
Line 734: Keeping dependencies injected via constructor is consistent with the DI direction in this file.

packages/features/webhooks/lib/service/BookingWebhookService.ts (1)

105-120: requestReschedule propagation is correct.
Line 119: Forwarding the flag from params into the DTO matches the new payload shape.

packages/trpc/server/routers/viewer/bookings/requestReschedule.handler.ts (2)

106-106: Safer event defaulting.
Line 106: Defaulting to eventType ?? {} avoids undefined access while preserving type intent.


274-279: Cancelled payload enrichment looks consistent.
Line 274-279: Adding event metadata plus requestReschedule: true aligns the reschedule cancellation with the new webhook contract.

packages/features/webhooks/lib/factory/base/BaseBookingPayloadBuilder.ts (1)

14-18: Extra data map update is appropriate.
Line 14-18: Adding requestReschedule to the BOOKING_CANCELLED extra data keeps type coverage aligned with the new payload.

packages/lib/server/service/BookingWebhookFactory.ts (2)

52-57: Cancelled payload interface expansion is sound.
Line 52-57: Optional metadata fields match the new cancellation payload needs.


130-135: Defaults and status assignment are consistent.
Line 130-135: Emitting status: "CANCELLED" plus null/false defaults keeps payloads stable for consumers.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines 45 to 50
extra: {
cancelledBy: dto.cancelledBy,
cancellationReason: dto.cancellationReason,
requestReschedule: dto.requestReschedule ?? true,
},
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Default value for requestReschedule should be false, not true.

A booking cancellation where requestReschedule is not explicitly set should default to false, indicating a regular cancellation. The current default of true contradicts the documentation which shows requestReschedule: false for standard cancellations. Only reschedule-triggered cancellations should explicitly set this to true.

🐛 Proposed fix
       extra: {
         cancelledBy: dto.cancelledBy,
         cancellationReason: dto.cancellationReason,
-        requestReschedule: dto.requestReschedule ?? true,
+        requestReschedule: dto.requestReschedule ?? false,
       },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
extra: {
cancelledBy: dto.cancelledBy,
cancellationReason: dto.cancellationReason,
requestReschedule: dto.requestReschedule ?? true,
},
});
extra: {
cancelledBy: dto.cancelledBy,
cancellationReason: dto.cancellationReason,
requestReschedule: dto.requestReschedule ?? false,
},
});
🤖 Prompt for AI Agents
In
`@packages/features/webhooks/lib/factory/versioned/v2021-10-20/BookingPayloadBuilder.ts`
around lines 45 - 50, In BookingPayloadBuilder, the extra.requestReschedule
default is incorrect; change the logic that sets extra.requestReschedule
(currently dto.requestReschedule ?? true) so it defaults to false when
dto.requestReschedule is undefined, i.e. use dto.requestReschedule ?? false (or
equivalent) so only explicit reschedule cancellations set it true; update the
assignment in the block that constructs extra (fields cancelledBy,
cancellationReason, requestReschedule) to reflect this.

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.

3 participants