Skip to content

fix(availability): don't offer round-robin slots when a mandatory fixed host is unavailable#29797

Open
shafi-VM wants to merge 1 commit into
calcom:mainfrom
shafi-VM:fix/rr-fixed-host-availability-leak
Open

fix(availability): don't offer round-robin slots when a mandatory fixed host is unavailable#29797
shafi-VM wants to merge 1 commit into
calcom:mainfrom
shafi-VM:fix/rr-fixed-host-availability-leak

Conversation

@shafi-VM

@shafi-VM shafi-VM commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #29800

getAggregatedAvailability dropped the fixed-host constraint whenever the fixed hosts' intersection was empty — but that's empty both when there are no fixed hosts and when fixed hosts exist but can't overlap (a mandatory host is busy). fixedDateRanges.length ? [fixedDateRanges] : [] conflated them, so a ROUND_ROBIN event with a busy fixed host leaked slots driven by the round-robin hosts alone — slots the booking layer then rejects with FixedHostsUnavailableForBooking. Gating on fixedHosts.length instead forces an empty fixed-host intersection to make the aggregate empty.

Visual Demo (For contributors especially)

Backend logic fix with no UI surface — demonstrated with a red→green unit test rather than a recording (see How should this be tested?).

Video Demo (if applicable):

N/A — no UI change.

Image Demo (if applicable):

N/A — no UI change.

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 if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. — N/A (no developer-facing API or docs change)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Data: a ROUND_ROBIN event with a fixed host + round-robin host(s); make the fixed host busy while a round-robin host is free.
  • Expected: no slots are offered for the busy fixed host's times (previously they were offered and then failed at booking with FixedHostsUnavailableForBooking).
  • Automated: new unit test in getAggregatedAvailability.test.ts asserts a ROUND_ROBIN input with a busy fixed host + an available round-robin host returns [] — verified red before the fix, green after; the other 10 tests in the file and the broader availability/schedules suites (213 tests) are unaffected.

Checklist

  • N/A — follows the contributing guide and style guidelines, tests included, PR is small (2 files, ~28 lines).

…ed host is unavailable

getAggregatedAvailability dropped the fixed-host constraint whenever the fixed hosts' intersection was empty — but that is empty in two different cases: (a) there are no fixed hosts, and (b) fixed hosts exist but can't overlap (a mandatory host is busy). The `fixedDateRanges.length ? [fixedDateRanges] : []` check conflated them, so for a ROUND_ROBIN event with a busy fixed host the aggregate was driven by the round-robin hosts alone, leaking bookable slots the booking layer then rejects (FixedHostsUnavailableForBooking).

Gate on `fixedHosts.length` instead, so an empty fixed-host intersection forces the aggregate empty. Adds a regression test; existing availability/schedules tests (213) unaffected.
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @shafi-VM! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@shafi-VM
shafi-VM marked this pull request as ready for review July 18, 2026 13:51
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updated getAggregatedAvailability to retain the fixed-host constraint when fixed hosts have no overlapping availability, resulting in no aggregated slots. Added a Vitest regression test covering an unavailable mandatory fixed host alongside an available round-robin host.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code change and new test address #29796 by preserving fixed-host constraints and returning no slots when a fixed host is busy.
Out of Scope Changes check ✅ Passed The PR only changes the targeted availability logic and adds a regression test, with no unrelated scope detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly summarizes the main availability fix and matches the changed behavior.
Description check ✅ Passed The description accurately explains the bug, fix, and regression test added in this PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: round-robin events offer bookable slots when a mandatory fixed host is unavailable

1 participant