-
Notifications
You must be signed in to change notification settings - Fork 11.6k
fix: Event Type empty title validation #23220
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
fix: Event Type empty title validation #23220
Conversation
|
@vitormrmonteiro is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (08/20/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (08/20/25)1 label was added to this PR based on Keith Williams's automation. |
WalkthroughThe change updates Zod validation for the title field in two schemas. In packages/prisma/zod/custom/eventtype.ts, the title validators in createEventTypeInput and EventTypeDuplicateInput were modified from z.string().min(1) to z.string().trim().min(1). No other fields or logic were altered. Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNone found. Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/prisma/zod/custom/eventtype.ts (2)
22-22: Optional: DRY the title schema (+ stable message if UI asserts on it).If this validation appears in other Event Type schemas, extract a shared schema to avoid drift and optionally set a stable message if tests/UI rely on copy. Apply this diff here, and mirror it in Line 48:
- title: z.string().trim().min(1), + title: titleSchema,Add this helper near the top of the file (outside the selected range):
const titleSchema = z.string().trim().min(1);If your UI/tests expect a specific message (e.g., “At least 1 character is required”), you can set it once here:
const titleSchema = z.string().trim().min(1, { message: "At least 1 character is required" });
48-48: Optional: apply the shared schema here too.Match the DRY refactor suggested above.
- title: z.string().trim().min(1), + title: titleSchema,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/prisma/zod/custom/eventtype.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts
📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
packages/prisma/zod/custom/eventtype.ts
**/*.{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/prisma/zod/custom/eventtype.ts
🔇 Additional comments (3)
packages/prisma/zod/custom/eventtype.ts (3)
22-22: Whitespace-only titles now correctly rejected. LGTM.Using z.string().trim().min(1) ensures the value is sanitized and whitespace-only input fails the min check. This matches the PR objective.
48-48: Consistent validation on duplicate input. LGTM.Mirrors the create schema; duplication will no longer accept whitespace-only titles.
22-22: Ensure.trim()Is Applied to AlltitleValidators Across Event-Type WorkflowsWe found multiple Zod schemas defining
title: z.string()(with or without.min()/.optional()) that are missing a.trim()before validation. Please update each instance to usez.string().trim()(and then apply.min(),.optional(), etc.) for consistent behavior across create, duplicate, and update flows.Files & locations needing fixes:
- packages/lib/server/service/InsightsBookingBaseService.ts:68
- packages/features/tasker/tasks/translateEventTypeData.ts:12
- packages/features/eventtypes/components/CreateEventTypeDialog.tsx:47
- packages/features/eventtypes/components/DuplicateDialog.tsx:27
- apps/web/app/api/social/og/image/route.tsx:13, 29
- apps/api/v1/lib/validations/booking.ts:61
- apps/api/v1/lib/validations/event-type.ts:84, 105
Example change:
- title: z.string() + title: z.string().trim()or, if you need to enforce a minimum length/optional:
- title: z.string().min(1) + title: z.string().trim().min(1)Likely an incorrect or invalid review comment.
|
@volnei @anikdhabal who should I reach out to in order to get this over the line? |
E2E results are ready! |
What does this PR do?
Before this PR, creating a new Event Type succeeded when the Title field contained only whitespace (e.g.,
" "). The value is not trimmed before validation, so an effectively empty title is accepted. This leads to Event Types with blank titles in the UI and database.This PR attempts to fix this problem by trimming the title input. Therefore, when entering a new event type, if the user enters a whitespace into the title field, the system will now display an error saying that "At least 1 character is required".
Visual Demo (For contributors especially)
Video Demo (if applicable):
Bug
https://app.birdeatsbug.com/FyLBcHxQKiGxsxz5hNF1cY1THIdJhDLZ14js-InEZ2LX
Image Demo (if applicable):
Solution

Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Checklist