Skip to content

fix(api/v2): make attendee email required in booking schema#28799

Open
ReetamBG wants to merge 2 commits intocalcom:mainfrom
ReetamBG:fix/v2-booking-email-required
Open

fix(api/v2): make attendee email required in booking schema#28799
ReetamBG wants to merge 2 commits intocalcom:mainfrom
ReetamBG:fix/v2-booking-email-required

Conversation

@ReetamBG
Copy link
Copy Markdown

@ReetamBG ReetamBG commented Apr 8, 2026

What does this PR do?

This PR enforces the attendee email as a required field in the V2 booking schema (CreateBookingInput_2024_04_15). Previously, the validation used a custom logic !value || isEmail(value) which allowed falsy values (like empty strings) to pass. This misled the OpenAPI/Swagger generator into marking the field as optional in the documentation.

By replacing the custom logic with a strict @isemail() decorator, the API now correctly rejects missing emails with a 400 Bad Request.
    

Visual Demo (For contributors especially)

Verified the fix via local API request. Below is the response when email is omitted from the request object:
Request object:

    {
          "eventTypeId": 174,
          "start": "2027-09-10T10:00:00Z",
          "timeZone": "Asia/Kolkata",
          "language": "en",
          "metadata": {},
          "responses": {
            "name": "xyz"
        }
    }

    
Response object:

    {
        "status": "error",
        "timestamp": "2026-04-08T19:46:17.623Z",
        "path": "/v2/bookings",
        "error": {
            "code": "BadRequestException",
            "message": "Bad Request Exception",
            "details": {
                "errors": [
                    {
                        "target": {
                            "eventTypeId": 174,
                            "start": "2027-09-10T10:00:00Z",
                            "timeZone": "Asia/Kolkata",
                            "language": "en",
                            "metadata": {},
                            "responses": {
                                "name": "xyz"
                            }
                        },
                        "value": {
                            "name": "xyz"
                        },
                        "property": "responses",
                        "children": [
                            {
                                "target": {
                                    "name": "xyz"
                                },
                                "property": "email",
                                "children": [],
                                "constraints": {
                                    "isEmail": "Email is required and must be a valid email address"
                                }
                            }
                        ]
                    }
                ]
            }
        }
    }

      
      

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?

  • Environment: Run the local stack using yarn dx and yarn workspace @calcom/api-v2 dev.
  • Minimal test data: A valid eventTypeId and a JSON body for POST /v2/bookings.
  • Expected result: Omitting the email field in the responses object should now return a 400 Bad Request with a validation error specifically for the email property.  
          

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have checked if my changes generate no new warnings
  • My PR is small and focused on the identified bug

@ReetamBG ReetamBG requested a review from a team as a code owner April 8, 2026 20:06
@github-actions github-actions bot added the 🐛 bug Something isn't working label Apr 8, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 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: f6f2aa6e-29f6-4899-9712-4550aa85002d

📥 Commits

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

📒 Files selected for processing (1)
  • apps/api/v2/src/ee/bookings/2024-04-15/inputs/create-booking.input.ts

📝 Walkthrough

Walkthrough

This change updates the email validation in the create-booking input file. The Response.email field validation was refactored from a custom @Validate predicate to the @IsEmail decorator from class-validator. The new validation is stricter—it now requires the email field to be present and valid, whereas the previous implementation allowed empty or missing values. The validation error message was updated accordingly to reflect this stricter requirement.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making attendee email required in the booking schema validation.
Description check ✅ Passed The description is directly related to the changeset, explaining the validation change, providing context about the issue, demonstrating the fix with examples, and detailing testing procedures.
Linked Issues check ✅ Passed The PR successfully addresses issue #28795 by replacing the permissive custom validator with a strict @IsEmail() decorator that now correctly enforces email as required.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the email validation in the CreateBookingInput schema, directly addressing the linked issue with no extraneous modifications.
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.

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/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2/bookings docs update needed, requires attendee.email

2 participants