Skip to content

fix(api-v2-bookings): prevent loss of user provided emails when email is hidden but still passed#28845

Open
bandhan-majumder wants to merge 2 commits intocalcom:mainfrom
bandhan-majumder:fix-25432
Open

fix(api-v2-bookings): prevent loss of user provided emails when email is hidden but still passed#28845
bandhan-majumder wants to merge 2 commits intocalcom:mainfrom
bandhan-majumder:fix-25432

Conversation

@bandhan-majumder
Copy link
Copy Markdown
Contributor

What does this PR do?

Adds user provided email in in the parsed data when event type has email hdden but user still passes email in the request body object

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

Before:

before.mp4

After:

after.mp4

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. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. create an event with hiding email and enabling phone number in the advanced tab
  2. create an api key
  3. Use api client and
    send this type of data :
{
  "start": "2026-07-21T10:00:00Z",
  "eventTypeId": 1157,
  "eventTypeSlug": "test-api-v2",
  "attendee": {
    "name": "Pro Example",
    "email": "pro23@example.com",
    "phoneNumber": "+919200000000",
    "timeZone": "Asia/Kolkata",
    "language": "en"
  },
  "guests": [],
  "location": {
    "type": "integration",
    "integration": "cal-video"
  },
  "metadata": {},
  "bookingFieldsResponses": {
    "customField": "customValue"
  }
}

with headers:

Authorization: <API_TOKEN>
cal-api-version: 2024-08-13
Content-Type: application/json

  1. look at the response
  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings
  • My PR is too large (>500 lines or >10 files) and should be split into smaller PRs

@bandhan-majumder bandhan-majumder requested a review from a team as a code owner April 12, 2026 11:17
@github-actions github-actions bot added Stale 🐛 bug Something isn't working labels Apr 12, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9445312-0f60-4e14-8395-06e084998f54

📥 Commits

Reviewing files that changed from the base of the PR and between 76dddb4 and ff6695f.

📒 Files selected for processing (1)
  • packages/features/bookings/lib/handleNewBooking/getBookingData.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/features/bookings/lib/handleNewBooking/getBookingData.ts

📝 Walkthrough

Walkthrough

The booking data handler was changed to copy reqBody.responses?.email into parsedBody.responses.email after schema.parseAsync(reqBody) when parsedBody.responses exists but its email field is missing. Tests were added covering two scenarios: (1) reqBody.responses.email present but omitted by the schema → resulting email comes from reqBody; (2) email hidden and absent from reqBody.responses → resulting email is undefined. Existing location extraction tests were left unchanged.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing loss of user-provided emails when the email field is hidden but still passed in the request.
Description check ✅ Passed The description is related to the changeset, explaining what the PR does, providing testing instructions, and referencing the linked issues.
Linked Issues check ✅ Passed The code changes directly address issue #25432 by preserving user-provided emails when the email field is hidden, implementing the required fallback logic.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the email preservation issue: modifications to getBookingData.ts and corresponding tests in getBookingData.test.ts are directly related to the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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: 1

🤖 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/handleNewBooking/getBookingData.ts`:
- Around line 27-30: The code in getBookingData.ts dereferences
reqBody.responses.email and parsedBody.responses.email without ensuring
responses exists; update the conditional to guard nested access (use
reqBody.responses?.email) and ensure parsedBody.responses is initialized before
assigning (e.g., if (reqBody.responses?.email && !parsedBody.responses?.email) {
parsedBody.responses = parsedBody.responses || {}; parsedBody.responses.email =
reqBody.responses.email; }) so accessing/setting email cannot throw; adjust the
conditional around reqBody and parsedBody in the getBookingData logic
accordingly.
🪄 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: 279564bd-7ce6-4fb5-8098-e78b11b0ce4e

📥 Commits

Reviewing files that changed from the base of the PR and between d08f4a0 and 76dddb4.

📒 Files selected for processing (2)
  • packages/features/bookings/lib/handleNewBooking/getBookingData.test.ts
  • packages/features/bookings/lib/handleNewBooking/getBookingData.ts

@github-actions github-actions bot removed the Stale label Apr 13, 2026
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/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create booking via API overwrites email with phone confirmation when the email field is not visible

1 participant