Skip to content

Comments

fix: resolve 404 error when rescheduling seated event bookings due type mismatch#23956

Merged
anikdhabal merged 10 commits intomainfrom
devin/1758308960-fix-reschedule-select-field-validation
Sep 22, 2025
Merged

fix: resolve 404 error when rescheduling seated event bookings due type mismatch#23956
anikdhabal merged 10 commits intomainfrom
devin/1758308960-fix-reschedule-select-field-validation

Conversation

@anikdhabal
Copy link
Contributor

@anikdhabal anikdhabal commented Sep 19, 2025

What does this PR do?

Updated packages/features/form-builder/FormBuilder.tsx: in handleSubmit, added a guard for fields named "guests" requiring type "multiemail"; on mismatch, calls showToast with "guests_field_must_be_multiemail" and returns early before duplicate-field checks.

Updated tests in packages/features/form-builder/FormBuilder.test.tsx: imported screen and waitFor; mocked @calcom/ui/components/toast.showToast; added tests verifying rejection for non-multiemail guests field and acceptance for multiemail. No public API signatures changed.

…edule

- Modify hasRequiredBookingFieldsResponses to detect reschedule context
- Skip validation for select, multiselect, checkbox, and radio fields during reschedule to preserve existing responses
- Fixes validation error when rescheduling bookings with select field responses that may no longer match current field options

Resolves issue where reschedule operations fail with 'Value Travel, Adventure & Wildlife is not valid for type select for field Niche-project' error

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 19, 2025

Walkthrough

  • Added English locale key: guests_field_must_be_multiemail with value "Guests field must be of type 'Multiple emails'" in apps/web/public/static/locales/en/common.json.
  • Updated packages/features/form-builder/FormBuilder.tsx: in handleSubmit, added a guard for fields named "guests" requiring type "multiemail"; on mismatch, calls showToast with "guests_field_must_be_multiemail" and returns early before duplicate-field checks.
  • Updated tests in packages/features/form-builder/FormBuilder.test.tsx: imported screen and waitFor; mocked @calcom/ui/components/toast.showToast; added tests verifying rejection for non-multiemail guests field and acceptance for multiemail. No public API signatures changed.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed The PR description clearly states the added guard in FormBuilder.handleSubmit for fields named "guests", the added translation key, and the new tests that mock showToast and verify rejection/acceptance; these points align with the raw summaries and therefore the description is related to the changeset. The level of detail is sufficient for this lenient check.
Title Check ✅ Passed The title "fix: resolve 404 error when rescheduling seated event bookings due type mismatch" clearly references the reschedule/type-mismatch bug that the PR addresses and therefore is related to the changeset. The PR actually contains two related fixes — skipping frontend validation for existing responses during reschedule and disabling edits to the guests field for seated events — and the title highlights the reschedule 404 aspect but does not mention the UI restriction. Overall the title is specific and meaningful enough for a teammate to understand the primary bug being fixed.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1758308960-fix-reschedule-select-field-validation

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.

@keithwillcode keithwillcode added the core area: core, team members only label Sep 19, 2025
@calcom calcom deleted a comment from devin-ai-integration bot Sep 19, 2025
…ing reschedule

- Revert backend changes in bookings.service.ts as the issue is frontend-only
- Add reschedule detection in getBookingResponsesSchema.ts preprocess function
- Skip option validation for select, radio, multiselect, and checkbox fields during reschedule
- Preserves existing booking responses that may no longer match current field options
- Fixes error 'Value Travel, Adventure & Wildlife is not valid for type select for field Niche-project' during slot selection

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
@vercel
Copy link

vercel bot commented Sep 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Sep 22, 2025 11:08am
cal-eu Ignored Ignored Sep 22, 2025 11:08am

…ke guests

- Add reschedule-aware logic to multiemail validation in getBookingResponsesSchema.ts
- Skip validation for existing multiemail responses during reschedule to avoid type mismatch errors
- Fixes 'Value is not valid for type text for field guests' error during slot selection
- Complements existing fix for select/radio field validation during reschedule

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
devin-ai-integration bot and others added 3 commits September 22, 2025 09:26
- Disable type SelectField for guests field in seated events
- Disable identifier InputField for guests field in seated events
- Add validation to prevent saving guests field changes for seated events
- Pass seatsEnabled prop from EventAdvancedTab to FormBuilder
- Use condition: seatsEnabled && formFieldType === 'multiemail' && fieldForm.getValues('name') === 'guests'
- Fix linting warnings: remove unused variable and add missing dependency

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>
…tion

Reconciling divergent branches:
- Remote: Previous reschedule validation fix
- Local: New seated events guests field restriction implementation

This merge combines the work to implement guests field input disabling for seated events.
@pull-request-size pull-request-size bot added size/S and removed size/M labels Sep 22, 2025
@pull-request-size pull-request-size bot added size/M and removed size/S labels Sep 22, 2025
@anikdhabal anikdhabal marked this pull request as ready for review September 22, 2025 11:08
@graphite-app graphite-app bot requested a review from a team September 22, 2025 11:08
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking seats area: seats, guest meetings, multiple people 🐛 bug Something isn't working labels Sep 22, 2025
Copy link
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: 0

🧹 Nitpick comments (4)
packages/features/form-builder/FormBuilder.tsx (2)

383-387: Harden the "guests" check (normalize identifier).

Relying on exact equality can miss variants (whitespace/case). Normalize before comparing.

Apply this diff:

-            if (data.name === "guests" && type !== "multiemail") {
+            const normalizedName = String(data.name || "").trim().toLowerCase();
+            if (normalizedName === "guests" && type !== "multiemail") {
               showToast(t("guests_field_must_be_multiemail"), "error");
               return;
             }

957-957: Missing translation key used in tooltip.

t("Toggle Variant") appears to reference a non-existent key; it will fall back to the literal. Either add a key (e.g., toggle_variant) to locales or reuse an existing one.

packages/features/form-builder/FormBuilder.test.tsx (2)

8-9: Mocking toast is correct; clear between tests to avoid leakage.

Add a beforeEach(() => vi.clearAllMocks()) in this describe to isolate calls.

Apply this diff inside "Guests Field Validation Tests" describe:

 describe("Guests Field Validation Tests", () => {
+  beforeEach(() => {
+    vi.clearAllMocks();
+  });

Also applies to: 37-39


280-314: Assertion on toast message may be brittle.

Tests assume t(k) === k. If localization changes to return real strings, this will fail. Prefer asserting toast was called with any string (or derive expected via t).

Example change:

-        expect(showToast).toHaveBeenCalledWith("guests_field_must_be_multiemail", "error");
+        expect(showToast).toHaveBeenCalledWith(expect.any(String), "error");
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c5942bc and bbad8ae.

📒 Files selected for processing (3)
  • apps/web/public/static/locales/en/common.json (1 hunks)
  • packages/features/form-builder/FormBuilder.test.tsx (3 hunks)
  • packages/features/form-builder/FormBuilder.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/form-builder/FormBuilder.tsx
  • packages/features/form-builder/FormBuilder.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/form-builder/FormBuilder.tsx
  • packages/features/form-builder/FormBuilder.test.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/form-builder/FormBuilder.tsx
  • packages/features/form-builder/FormBuilder.test.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.
Learnt from: anglerfishlyy
PR: calcom/cal.com#0
File: :0-0
Timestamp: 2025-08-27T16:39:38.192Z
Learning: anglerfishlyy successfully implemented CAL-3076 email invitation feature for Cal.com team event-types in PR #23312. The feature allows inviting people via email directly from assignment flow, with automatic team invitation if email doesn't belong to existing team member. Implementation includes Host type modifications (userId?: number, email?: string, isPending?: boolean), CheckedTeamSelect component updates with CreatableSelect, TRPC schema validation with zod email validation, and integration with existing teamInvite system.
Learnt from: hariombalhara
PR: calcom/cal.com#23736
File: packages/features/bookings/lib/reschedule/determineReschedulePreventionRedirect.ts:73-84
Timestamp: 2025-09-12T11:23:34.158Z
Learning: In the Cal.com codebase, the forceRescheduleForCancelledBooking flag historically affects both CANCELLED and REJECTED booking statuses, despite its name suggesting it should only affect cancelled bookings. This behavior existed before PR #23736 and was preserved during the refactoring.
📚 Learning: 2025-08-29T22:57:30.382Z
Learnt from: bandhan-majumder
PR: calcom/cal.com#23454
File: packages/features/form-builder/FormBuilder.tsx:11-11
Timestamp: 2025-08-29T22:57:30.382Z
Learning: FormBuilder.tsx in packages/features/form-builder/ does not have "use client" directive at the top despite using client-side React hooks and event handlers, which suggests it should be a client component.

Applied to files:

  • packages/features/form-builder/FormBuilder.tsx
  • packages/features/form-builder/FormBuilder.test.tsx
📚 Learning: 2025-08-27T13:32:46.887Z
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.

Applied to files:

  • packages/features/form-builder/FormBuilder.test.tsx
🧬 Code graph analysis (1)
packages/features/form-builder/FormBuilder.test.tsx (1)
packages/features/form-builder/testUtils.ts (2)
  • mockProps (18-26)
  • pageObject (92-237)
🔇 Additional comments (2)
apps/web/public/static/locales/en/common.json (1)

2205-2205: LGTM: i18n key added for guests-type validation.

Key is correctly placed above the sentinel and used by the UI.

If you maintain non-English locales, consider adding this key there or confirm fallback-to-en is acceptable.

packages/features/form-builder/FormBuilder.test.tsx (1)

2-2: LGTM: waitFor import added for async assertions.

@anikdhabal anikdhabal changed the title fix: skip select field validation for existing responses during reschedule fix: resolve 404 error when rescheduling seated event bookings Sep 22, 2025
@anikdhabal anikdhabal enabled auto-merge (squash) September 22, 2025 11:14
@anikdhabal anikdhabal changed the title fix: resolve 404 error when rescheduling seated event bookings fix: resolve 404 error when rescheduling seated event bookings due type mismatch Sep 22, 2025
@anikdhabal anikdhabal merged commit f3d60b1 into main Sep 22, 2025
87 of 90 checks passed
@anikdhabal anikdhabal deleted the devin/1758308960-fix-reschedule-select-field-validation branch September 22, 2025 23:44
@github-actions
Copy link
Contributor

E2E results are ready!

saurabhraghuvanshii pushed a commit to saurabhraghuvanshii/cal.com that referenced this pull request Sep 24, 2025
…m#23956)

* fix: skip select field validation for existing responses during reschedule

- Modify hasRequiredBookingFieldsResponses to detect reschedule context
- Skip validation for select, multiselect, checkbox, and radio fields during reschedule to preserve existing responses
- Fixes validation error when rescheduling bookings with select field responses that may no longer match current field options

Resolves issue where reschedule operations fail with 'Value Travel, Adventure & Wildlife is not valid for type select for field Niche-project' error

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* fix: skip frontend validation for existing select field responses during reschedule

- Revert backend changes in bookings.service.ts as the issue is frontend-only
- Add reschedule detection in getBookingResponsesSchema.ts preprocess function
- Skip option validation for select, radio, multiselect, and checkbox fields during reschedule
- Preserves existing booking responses that may no longer match current field options
- Fixes error 'Value Travel, Adventure & Wildlife is not valid for type select for field Niche-project' during slot selection

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* fix: extend reschedule validation skip to handle multiemail fields like guests

- Add reschedule-aware logic to multiemail validation in getBookingResponsesSchema.ts
- Skip validation for existing multiemail responses during reschedule to avoid type mismatch errors
- Fixes 'Value is not valid for type text for field guests' error during slot selection
- Complements existing fix for select/radio field validation during reschedule

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* fix: disable guests field inputs for seated events

- Disable type SelectField for guests field in seated events
- Disable identifier InputField for guests field in seated events
- Add validation to prevent saving guests field changes for seated events
- Pass seatsEnabled prop from EventAdvancedTab to FormBuilder
- Use condition: seatsEnabled && formFieldType === 'multiemail' && fieldForm.getValues('name') === 'guests'
- Fix linting warnings: remove unused variable and add missing dependency

Co-Authored-By: anik@cal.com <adhabal2002@gmail.com>

* Update getBookingResponsesSchema.ts

* Update FormBuilder.tsx

* Update FormBuilder.tsx

* update

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working core area: core, team members only ready-for-e2e seats area: seats, guest meetings, multiple people size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants