Skip to content

fix: (booking-audit) Remove IS_PRODUCTION gate and add feature flag check in producer#26524

Merged
volnei merged 24 commits intomainfrom
devin/remove-is-production-gate-booking-audit-1767765908
Feb 9, 2026
Merged

fix: (booking-audit) Remove IS_PRODUCTION gate and add feature flag check in producer#26524
volnei merged 24 commits intomainfrom
devin/remove-is-production-gate-booking-audit-1767765908

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara commented Jan 7, 2026

What does this PR do?

Removes the IS_PRODUCTION check from BookingAuditTaskerProducerService and adds a feature flag check in the producer to avoid creating unnecessary audit tasks when the booking-audit feature is disabled.

Why derive the feature flag early?

The isBookingAuditEnabled flag is derived very early, before calling BookingEventHandlerService methods. This design allows callers to query the booking-audit feature flag alongside other feature flags (like booking-email-sms-tasker) using Promise.all(), reducing the total number of sequential DB queries and keeping the booking flow fast.

For example, in RegularBookingService:

const [isBookingEmailSmsTaskerEnabled, isBookingAuditEnabled] = await Promise.all([
  deps.featuresRepository.checkIfTeamHasFeature(orgId, "booking-email-sms-tasker"),
  deps.featuresRepository.checkIfTeamHasFeature(orgId, "booking-audit"),
]);

This parallel querying pattern ensures that adding the booking-audit check has minimal impact on booking latency.

Changes

  • Removed IS_PRODUCTION gate from BookingAuditTaskerProducerService
  • Made isBookingAuditEnabled: boolean required in all BookingAuditProducerService interface methods
  • Updated all callers to query the feature flag using orgId and pass it to BookingEventHandlerService:
    • RegularBookingService, RecurringBookingService, handleSeats
    • handleCancelBooking, handleConfirmation
    • roundRobinReassignment, roundRobinManualReassignment
    • tRPC handlers: addGuests, confirm, editLocation, requestReschedule
    • API V2: BookingLocationService_2024_08_13, RecurringBookingService
  • Added debug logging when skipping audit (logs organizationId, bookingUid, and action)
  • Updated tests to include isBookingAuditEnabled in expected call assertions

Updates since last revision

  • Fixed organization ID source in addGuests.handler.ts: Changed from using user.organizationId (actor's org) to booking.user?.profiles?.[0]?.organizationId (booking's org). This ensures the feature flag is checked against the booking's organization, consistent with other handlers in this PR. (Addresses Cubic AI review feedback)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - no documentation changes needed.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Verify booking audits are queued when the booking-audit feature flag is enabled for the organization
  2. Verify booking audits are NOT queued when the feature flag is disabled (check debug logs)
  3. Test all flows: regular booking, recurring booking, seat booking, cancellation, confirmation, reassignment, location change, add guests, request reschedule

Human Review Checklist

  • Verify addGuests.handler.ts uses booking.user?.profiles?.[0]?.organizationId consistently with other handlers (e.g., editLocation.handler.ts, booking-location.service.ts)
  • Confirm the feature flag check pattern is consistent across all updated files

Checklist

  • My code follows the style guidelines of this project
  • I have checked if my changes generate no new warnings

Link to Devin run

https://app.devin.ai/sessions/43f5c78d649d47139d4f9bd4cc3d8599

Requested by

@hariombalhara


Open with Devin

Remove the IS_PRODUCTION check that was preventing booking audits from
being queued in production. Audits are still properly gated by:

1. Organization check: Audits are skipped for non-organization bookings
   (organizationId === null)
2. Feature flag: The BookingAuditTaskConsumer checks if the 'booking-audit'
   feature is enabled for the organization via featuresRepository.checkIfTeamHasFeature()

The IS_PRODUCTION gate was intentionally added to prevent logs from being
created in production while the action data versioning was being actively
reviewed and finalized. Without proper versioning handling, the Booking
History UI could crash when encountering unversioned data. Now that the
versioning system is in place, this gate can be safely removed.

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Review Updated (UTC)
cal Ignored Ignored Jan 7, 2026 6:21am
cal-companion Ignored Ignored Preview Jan 7, 2026 6:21am
cal-eu Ignored Ignored Jan 7, 2026 6:21am

Reverts the unintended formatting changes from the previous commit.
Only removes the IS_PRODUCTION gate without changing indentation.

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Jan 18, 2026
devin-ai-integration bot and others added 2 commits February 2, 2026 06:02
…essary task creation

- Query booking-audit and booking-email-sms-tasker flags in parallel before fireBookingEvents
- Pass isBookingAuditEnabled through BookingEventHandler to producer's queueTask method
- Add conditional check in queueTask with debug log when skipping audit
- Reuse pre-queried isBookingEmailSmsTaskerEnabled flag instead of querying again

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@pull-request-size pull-request-size bot added size/M and removed size/XS labels Feb 2, 2026
@devin-ai-integration devin-ai-integration bot changed the title fix: remove IS_PRODUCTION gate from BookingAuditProducer fix: remove IS_PRODUCTION gate and add feature flag check in producer Feb 2, 2026
…king audit flows

- Make isBookingAuditEnabled a required property in BookingAuditProducerService interface
- Update all BookingEventHandler methods to require isBookingAuditEnabled
- Add feature flag check in all flows that call booking audit:
  - handleSeats (seat booking/rescheduling)
  - RecurringBookingService (bulk bookings)
  - handleCancelBooking (booking cancellation)
  - handleConfirmation (booking acceptance)
  - roundRobinReassignment (automatic reassignment)
  - roundRobinManualReassignment (manual reassignment)
  - trpc handlers: addGuests, confirm, editLocation, requestReschedule
- Skip queueing audit tasks when feature is disabled with debug logging

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@pull-request-size pull-request-size bot added size/L and removed size/M labels Feb 2, 2026
devin-ai-integration bot and others added 6 commits February 2, 2026 08:25
…module

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Keep feature flag check only in main flows (handleSeats, RegularBookingService, RecurringBookingService) which are frequently triggered. For other flows (handleCancelBooking, handleConfirmation, roundRobinReassignment, etc.), rely on the existing consumer-level check.

Changes:
- Revert feature flag check from non-main flows
- Make isBookingAuditEnabled optional in interface for non-main flow methods
- Keep isBookingAuditEnabled required for main flow methods (queueCreatedAudit, queueRescheduledAudit, queueSeatBookedAudit, queueSeatRescheduledAudit, queueBulkCreatedAudit, queueBulkRescheduledAudit)
- Update BookingEventHandlerService to use required params for main flows and optional for non-main flows

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…ervice methods

- Add isBookingAuditEnabled as required parameter in all BookingAuditProducerService interface methods
- Update BookingAuditTaskerProducerService to use simplified check (!params.isBookingAuditEnabled)
- Update BookingEventHandlerService to require isBookingAuditEnabled in all methods
- Update all callers to query booking-audit feature flag and pass isBookingAuditEnabled:
  - handleCancelBooking
  - handleConfirmation
  - roundRobinReassignment
  - roundRobinManualReassignment
  - addGuests.handler
  - confirm.handler
  - editLocation.handler
  - requestReschedule.handler
- Inject featuresRepository in API V2's booking-location.service.ts

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…abled

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…uditEnabled

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

E2E results are ready!

devin-ai-integration bot and others added 2 commits February 2, 2026 12:38
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
@hariombalhara hariombalhara marked this pull request as ready for review February 3, 2026 04:35
@hariombalhara hariombalhara requested a review from a team as a code owner February 3, 2026 04:35
@graphite-app graphite-app bot requested a review from a team February 3, 2026 04:36
@graphite-app graphite-app bot added the enterprise area: enterprise, audit log, organisation, SAML, SSO label Feb 3, 2026
@hariombalhara hariombalhara changed the title fix: remove IS_PRODUCTION gate and add feature flag check in producer fix: (booking-audit) Remove IS_PRODUCTION gate and add feature flag check in producer Feb 3, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 21 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:93">
P2: Feature-flag gating is based on the actor’s orgId, so attendee users without an org will disable audit for bookings that belong to an org with booking-audit enabled. Use the booking’s organization when checking the flag.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 3, 2026

Devin AI is addressing Cubic AI's review feedback

A Devin session has been created to address the issues identified by Cubic AI.

View Devin Session

devin-ai-integration bot and others added 3 commits February 3, 2026 04:48
…andler

Use booking.user?.profiles?.[0]?.organizationId instead of user.organizationId
to check the booking-audit feature flag. This ensures the feature flag is
checked against the booking's organization rather than the actor's organization,
which is consistent with other handlers in this PR.

Addresses Cubic AI review feedback (confidence 9/10).

Co-Authored-By: unknown <>
…8' of github.com:calcom/cal.com into devin/remove-is-production-gate-booking-audit-1767765908
Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:93">
P2: The booking-audit feature flag is now checked against the actor’s organization rather than the booking’s organization, which can skip or misapply audit logging for cross-org actions. Use the booking’s org ID instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit 34c76ee

devin-ai-integration bot and others added 2 commits February 6, 2026 09:58
… handler

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
…s handler

Co-Authored-By: hariom@cal.com <hariombalhara@gmail.com>
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/bookings/addGuests.handler.ts:93">
P2: Feature flag check should use the booking’s organization, not the acting user’s org, otherwise audit can be skipped or enabled incorrectly for cross-org actions. Align this with booking context by deriving orgId from the booking.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ No changes pushed (confidence score 8.5/10 is below 9/10 threshold, and user explicitly confirmed using user.organizationId is correct because the actor is in the same organization as the booking)

Copy link
Copy Markdown
Contributor

@volnei volnei left a comment

Choose a reason for hiding this comment

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

Great work! 🚀

@volnei volnei merged commit e04a394 into main Feb 9, 2026
56 checks passed
@volnei volnei deleted the devin/remove-is-production-gate-booking-audit-1767765908 branch February 9, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e size/L Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants