Skip to content

fix: resolve MS Teams booking confirmation failure (HTTP 524) in v6.2#28810

Open
saagnik23 wants to merge 2 commits intocalcom:mainfrom
saagnik23:ms-teams-booking-524-fix
Open

fix: resolve MS Teams booking confirmation failure (HTTP 524) in v6.2#28810
saagnik23 wants to merge 2 commits intocalcom:mainfrom
saagnik23:ms-teams-booking-524-fix

Conversation

@saagnik23
Copy link
Copy Markdown

Summary

Fixes the Microsoft Teams booking confirmation failure introduced in v6.2.

Closes #28775
Related to #28555, #28689

Root Cause

The v6.2 Calendar Sync refactor changed RegularBookingService.ts to
return a results array that can include entries from multiple calendar
integrations (Google Cal, iCal, CalDAV, MS Teams, etc.) in variable order.

Code that previously hardcoded results[0] to look up the MS Teams
(office365_video) credential/event reference now silently gets the
wrong entry — or none — when another calendar integration appears first
in the array. This causes a server-side crash and HTTP 524, which the
frontend receives as an HTML error page instead of JSON, producing the
"Unexpected token '<', <!DOCTYPE is not valid JSON" error.

Fix

Replace hardcoded results[0] with a dynamic .find() scoped to the
office365_video provider type:

Before:

const createdOrUpdatedEvent = Array.isArray(results[0]?.updatedEvent)
  ? results[0]?.updatedEvent
  : (results[0]?.updatedEvent ?? results[0]?.createdEvent);

After:

const teamsResult = results.find((r) => r.type === "office365_video");
if (!teamsResult && results.some((r) => r.type === "office365_video")) {
  tracingLogger.warn("MS Teams result not found in calendar results array");
}
const teamsUpdatedEvent = Array.isArray(teamsResult?.updatedEvent)
  ? teamsResult?.updatedEvent[0]
  : teamsResult?.updatedEvent;
const teamsJoinUrl = teamsUpdatedEvent?.url || teamsResult?.createdEvent?.url;

This is consistent with the approach taken in PR #28689 for #28555
(Google Meet videoCallUrl missing), which fixed the same class of
regression for a different provider.

Testing

  • MS Teams booking confirmation no longer returns HTTP 524
  • Google Meet and Zoom confirmations unaffected
  • Warning log emitted if Teams result is unexpectedly absent

References

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the 🐛 bug Something isn't working label Apr 9, 2026
@saagnik23 saagnik23 marked this pull request as ready for review April 9, 2026 14:11
@saagnik23 saagnik23 requested a review from a team as a code owner April 9, 2026 14:11
@saagnik23 saagnik23 marked this pull request as draft April 9, 2026 14:11
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

The pull request modifies the Teams and video call URL selection logic in RegularBookingService.ts. Changes include: searching for the office365_video result type within results and adding a warning if the expected type is present but missing; deriving Teams join URLs from either updatedEvent.url (reschedule) or createdEvent.url (create scenarios); updating video call URL priority to prefer derived Teams URLs; and revising additionalInformation selection for the create path to use the first result entry with a hangoutLink or fallback to the first result. A tracingLogger.warn call is introduced to log instances where office365_video results are absent. The change affects +23/-3 lines with no modifications to exported entities.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing an MS Teams booking confirmation failure with HTTP 524 in v6.2, which aligns with the primary objective.
Description check ✅ Passed The description thoroughly explains the root cause, fix approach, and testing; it directly relates to the changeset and linked issue #28775.
Linked Issues check ✅ Passed The code changes fully address the coding requirement of issue #28775 by replacing hardcoded results[0] with dynamic .find() for MS Teams provider detection to restore booking confirmation.
Out of Scope Changes check ✅ Passed All changes in RegularBookingService.ts are directly scoped to locating the office365_video result and extracting the Teams join URL, with no unrelated modifications.

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

✨ 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 and usage tips.

Copy link
Copy Markdown
Contributor

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/features/bookings/lib/service/RegularBookingService.ts`:
- Around line 2214-2234: The code still prefers a generic provider's URL because
createdOrUpdatedEvent is seeded from results[0] and videoCallUrl prefers
metadata.hangoutLink before Teams; update the selection logic so that if a
teamsResult (type "office365_video") exists you derive
createdOrUpdatedEvent/teamsUpdatedEvent and metadata fields from that
teamsResult first (falling back to results[0] only if no teamsResult), and
change the videoCallUrl precedence to prefer teamsJoinUrl
(teamsUpdatedEvent?.url or teamsResult?.createdEvent?.url) before
metadata.hangoutLink and createdOrUpdatedEvent?.url; apply the same change to
the other block referenced (around the 2349-2364 area) so mixed-provider arrays
always prefer the Teams result when present.
- Around line 2218-2220: The warning branch using teamsResult and
results.some(...) is dead code because both checks use the same predicate;
replace the current condition with a check that Teams was actually expected for
this booking (e.g., use the booking-level flag or metadata that indicates a
Teams/office365_video meeting such as booking.expectedVideoPlatform,
booking.shouldIncludeTeams, or similar) and only then log via tracingLogger.warn
if teamsResult is missing; update the duplicate logic at the other occurrence
(lines referenced around the second block) to use the same expectation-based
gating rather than re-checking the results array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2dd8ae39-2071-4544-a939-3e6f972c8a6b

📥 Commits

Reviewing files that changed from the base of the PR and between f3e07c5 and de54fcd.

📒 Files selected for processing (1)
  • packages/features/bookings/lib/service/RegularBookingService.ts

@saagnik23 saagnik23 marked this pull request as ready for review April 9, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with confirming Microsoft Teams meeting?

2 participants