-
Notifications
You must be signed in to change notification settings - Fork 11.2k
fix: preserve API-provided email when email field is hidden #25441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add new timeZone parameter to CalendarBusyTimesInput - Mark loggedInUsersTz as deprecated - Update getBusyTimes endpoint to prioritize timeZone parameter - Maintain backward compatibility with loggedInUsersTz - Add validation to ensure at least one timezone parameter is provided - Update API documentation with new parameter example Fixes calcom#25423
- Use custom ValidatorConstraint instead of problematic ValidateIf - Properly validate that at least one timezone parameter is provided - Improve code quality and clarity
When email field is hidden and phone confirmation is enabled, preserve explicitly provided emails instead of overwriting them with auto-generated phone emails. Added unit test to verify the fix works.
|
@Shikhar-8 is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this 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 4 files
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/platform/types/calendars/inputs/busy-times.input.ts">
<violation number="1" location="packages/platform/types/calendars/inputs/busy-times.input.ts:28">
`@Validate` is a property decorator; applying it to the class prevents the TimezoneRequiredValidator from ever running, so both timezone fields become optional and requests without any timezone now pass validation.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
| } | ||
| } | ||
|
|
||
| @Validate(TimezoneRequiredValidator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Validate is a property decorator; applying it to the class prevents the TimezoneRequiredValidator from ever running, so both timezone fields become optional and requests without any timezone now pass validation.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/platform/types/calendars/inputs/busy-times.input.ts, line 28:
<comment>`@Validate` is a property decorator; applying it to the class prevents the TimezoneRequiredValidator from ever running, so both timezone fields become optional and requests without any timezone now pass validation.</comment>
<file context>
@@ -14,14 +14,37 @@ export class Calendar {
+ }
+}
+
+@Validate(TimezoneRequiredValidator)
export class CalendarBusyTimesInput {
@ApiProperty({
</file context>
What does this PR do?
Problem
When email field is hidden and phone confirmation is enabled, API booking creation was overwriting provided emails with auto-generated phone emails (e.g.,
[email protected]).Solution
Added conditional check
&& !responses["email"]to only clear email when not explicitly provided via API. This preserves API-provided emails while maintaining session email protection.Testing
Closes #25432
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Tests Run
Unit tests: Added and ran test case hidden email field should preserve explicitly provided email from API in getBookingResponsesSchema.test.ts
Type checking: Ran yarn type-check to ensure no TypeScript errors
Linting: Ran yarn lint:fix to ensure code style compliance
How to Test :
Run the specific test: yarn test packages/features/bookings/lib/getBookingResponsesSchema.test.ts
Run all booking-related tests: yarn test packages/features/bookings
Environment Variables
No special environment variables required - uses standard Cal.com test configuration.
Minimal Test Data
The test creates an event type with:
hidden: true on the email field
required: true on the attendee phone number field
API booking request with explicit email: "[email protected]"
Expected Behavior (Happy Path)
Input:
{
"responses": {
"email": "[email protected]",
"attendeePhoneNumber": "+919999999999"
},
"eventType": {
"bookingFields": [
{
"name": "email",
"type": "email",
"hidden": true,
"required": false
},
{
"name": "attendeePhoneNumber",
"type": "phone",
"hidden": false,
"required": true
}
]
}
}
Expected Output:
{
"data": {
"email": "[email protected]", // ✅ Preserved from API input
"attendeePhoneNumber": "+919999999999"
}
}
Before Fix (Broken Behavior):
{
"data": {
"email": "[email protected]", // ❌ Overwritten with phone email
"attendeePhoneNumber": "+919999999999"
}
}
Additional Testing Notes
Test verifies the fix works when email is explicitly provided via API
Ensures backward compatibility when no email is provided (falls back to phone email generation)
No database changes required - pure logic fix
Test is isolated and doesn't require external services
Checklist