Skip to content

Conversation

@vitormrmonteiro
Copy link
Contributor

@vitormrmonteiro vitormrmonteiro commented Aug 20, 2025

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
image

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. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set? - No
  • What are the minimal test data to have? - Minimal dev setup
  • What is expected (happy path) to have (input and output)?
  1. Log In
  2. Go to Event Types
  3. Click on "Create"
  4. Add a whitespace in the "Title" field
  5. Enter a slug in the "URL" field
  6. Click "Continue"
  7. An error will be displayed preventing the form from being saved.
  • Any other important info that could help to test that PR - None

Checklist

@vitormrmonteiro vitormrmonteiro requested a review from a team August 20, 2025 16:11
@vercel
Copy link

vercel bot commented Aug 20, 2025

@vitormrmonteiro is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Aug 20, 2025
@graphite-app graphite-app bot requested a review from a team August 20, 2025 16:12
@github-actions github-actions bot added event-types area: event types, event-types 🐛 bug Something isn't working labels Aug 20, 2025
@github-actions
Copy link
Contributor

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:

Unknown release type "Fix" found in pull request title "Fix: Event Type empty title validation". 

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@graphite-app
Copy link

graphite-app bot commented Aug 20, 2025

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

The 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

Objective Addressed Explanation
Trim title before validation so whitespace-only titles are rejected [#23218, CAL-6282]

Assessment against linked issues: Out-of-scope changes

None 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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (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.

📥 Commits

Reviewing files that changed from the base of the PR and between e309e72 and 854f45d.

📒 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 use include, always use select
Ensure the credential.key field 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 All title Validators Across Event-Type Workflows

We 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 use z.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.

@vitormrmonteiro vitormrmonteiro changed the title Fix: Event Type empty title validation fix: Event Type empty title validation Aug 20, 2025
@volnei volnei enabled auto-merge (squash) August 20, 2025 22:16
@vitormrmonteiro
Copy link
Contributor Author

@volnei @anikdhabal who should I reach out to in order to get this over the line?
thanks

@github-actions
Copy link
Contributor

E2E results are ready!

@volnei volnei merged commit 6932498 into calcom:main Aug 28, 2025
55 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync event-types area: event types, event-types ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Type form allows " " as a valid title

5 participants