fix: resolve 404 error when rescheduling seated event bookings due type mismatch#23956
Conversation
…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>
Walkthrough
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate 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. Comment |
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…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>
- 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.
There was a problem hiding this comment.
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 viat).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.
📒 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.tsxpackages/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.tsxpackages/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.tsxpackages/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.tsxpackages/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.
E2E results are ready! |
…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>
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.