Skip to content

fix: changes to error on schedule name empty save#24044

Merged
anikdhabal merged 11 commits intocalcom:mainfrom
KirankumarAmbati:fix/schedule-name-cannot-be-empty
Jan 13, 2026
Merged

fix: changes to error on schedule name empty save#24044
anikdhabal merged 11 commits intocalcom:mainfrom
KirankumarAmbati:fix/schedule-name-cannot-be-empty

Conversation

@KirankumarAmbati
Copy link
Contributor

What does this PR do?

Visual Demo (For contributors especially)

Screenshot (34)

Mandatory Tasks (DO NOT REMOVE)

  • [ X ] I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • [ X ] 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.
  • [ X ] 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? - None
  • What are the minimal test data to have? - A schedule
  • What is expected (happy path) to have (input and output)? - Make the schedule title as empty & try saving the schedule
  • Any other important info that could help to test that PR

Checklist

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Walkthrough

This PR prevents blank schedule names by adding client- and server-side validation: the AvailabilitySettingsWebWrapper.handleSubmit in apps/web/modules/availability/[schedule]/schedule-view.tsx trims the name and shows an error toast using i18n key schedule_name_cannot_be_empty, returning early instead of calling updateMutation. The English locale apps/web/public/static/locales/en/common.json adds schedule_name_cannot_be_empty: "Schedule name cannot be empty". Server schemas were strengthened: ZCreateInputSchema now uses z.string().trim().min(1, "Schedule name cannot be empty") and ZUpdateInputSchema uses z.string().trim().min(1, "Schedule name cannot be empty").optional().

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly indicates that the pull request fixes the behavior when saving an empty schedule name by surfacing an error, which matches the core change implemented in the UI and schemas.
Linked Issues Check ✅ Passed The implementation fulfills the objectives from issues #21709 and CAL-5894 by enforcing non-empty schedule names in the UI submission handler, adding validation rules in both create and update schemas, and providing a localized error message.
Out of Scope Changes Check ✅ Passed All modifications pertain exclusively to preventing empty schedule names, including UI validation, localization, and schema updates, with no unrelated or extraneous changes present.
Description Check ✅ Passed The description clearly outlines that the PR fixes the linked issues, provides a demo screenshot, lists self-review and testing steps, and directly relates to preventing saving an empty schedule name.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link

CLAassistant commented Sep 24, 2025

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Sep 24, 2025
@graphite-app graphite-app bot requested a review from a team September 24, 2025 12:55
@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:

No release type found in pull request title "fix #21709: changes to error on schedule name empty save". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

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

@github-actions github-actions bot added ui area: UI, frontend, button, form, input 🐛 bug Something isn't working labels Sep 24, 2025
@vercel
Copy link

vercel bot commented Sep 24, 2025

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

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the bookings area: bookings, availability, timezones, double booking label Sep 24, 2025
@KirankumarAmbati KirankumarAmbati changed the title fix #21709: changes to error on schedule name empty save fix: changes to error on schedule name empty save Sep 24, 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: 1

🧹 Nitpick comments (1)
apps/web/modules/availability/[schedule]/schedule-view.tsx (1)

123-126: Defensive check and trim before mutate

.values.name may be undefined; .trim() would throw. Also, pass the trimmed name to the mutation to avoid persisting whitespace.

Apply within this block:

-        if (!values.name.trim()) {
+        const name = (values.name ?? "").trim();
+        if (!name) {
           showToast(t("schedule_name_cannot_be_empty"), "error");
           return;
         }

Then use the trimmed name in the mutation payload:

updateMutation.mutate({
  scheduleId,
  dateOverrides: dateOverrides.flatMap((override) => override.ranges),
  ...values,
  name, // ensures no leading/trailing spaces are saved
});
📜 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 57150d9 and e417d46.

📒 Files selected for processing (2)
  • apps/web/modules/availability/[schedule]/schedule-view.tsx (1 hunks)
  • apps/web/public/static/locales/en/common.json (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:

  • apps/web/modules/availability/[schedule]/schedule-view.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:

  • apps/web/modules/availability/[schedule]/schedule-view.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:

  • apps/web/modules/availability/[schedule]/schedule-view.tsx
🧠 Learnings (2)
📓 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.
📚 Learning: 2025-08-20T17:34:35.004Z
Learnt from: mdm317
PR: calcom/cal.com#23221
File: packages/features/schedules/components/NewScheduleButton.tsx:1-1
Timestamp: 2025-08-20T17:34:35.004Z
Learning: In the Cal.com codebase, server actions like `revalidateAvailabilityList()` from `app/(use-page-wrapper)/(main-nav)/availability/actions` are imported and called directly in client components within mutation `onSuccess` callbacks. This pattern is consistently used across availability-related components (both in availability-view.tsx for updates and NewScheduleButton.tsx for creates) to ensure the availability list cache is fresh after mutations.

Applied to files:

  • apps/web/modules/availability/[schedule]/schedule-view.tsx
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (1)
apps/web/public/static/locales/en/common.json (1)

3735-3735: Avoid duplicate i18n strings — ensure translations exist for schedule_name_cannot_be_empty

Reuse the existing key you_need_to_add_a_name if semantically identical; otherwise add schedule_name_cannot_be_empty to every locale to avoid missing translations at runtime.

Verification failed: the earlier script errored with "/bin/bash: line 5: !: command not found". Re-run this fixed check and paste the output:

#!/bin/bash
set -euo pipefail
base="apps/web/public/static/locales"
fd -t f common.json "$base" | while IFS= read -r f; do
  if rg -q '"schedule_name_cannot_be_empty"\s*:' "$f"; then
    :
  else
    echo "Missing in: $f"
  fi
done

volnei
volnei previously requested changes Sep 29, 2025
Copy link
Contributor

@volnei volnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment from Coderabbit. Also, would be good to update tests.

@pallava-joshi
Copy link
Contributor

please address code rabbit suggestions

@pallava-joshi pallava-joshi marked this pull request as draft October 8, 2025 05:57
@KirankumarAmbati KirankumarAmbati marked this pull request as ready for review October 10, 2025 07:49
@dosubot dosubot bot added the consumer label Oct 10, 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 (1)
packages/trpc/server/routers/viewer/availability/schedule/update.schema.ts (1)

8-8: LGTM! Validation logic is sound.

The validation chain correctly enforces a non-empty trimmed name when the field is provided during updates. The .optional() placement is appropriate—users may omit the name field, but if they supply it, it must be non-empty after trimming.

The error message "Schedule name cannot be empty" is duplicated in create.schema.ts (line 4). Consider extracting it to a shared constant:

const SCHEDULE_NAME_EMPTY_ERROR = "Schedule name cannot be empty";

Then reference it in both schemas:

-  name: z.string().trim().min(1, "Schedule name cannot be empty").optional(),
+  name: z.string().trim().min(1, SCHEDULE_NAME_EMPTY_ERROR).optional(),
📜 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 98dd0ce and 1e2ec40.

📒 Files selected for processing (2)
  • packages/trpc/server/routers/viewer/availability/schedule/create.schema.ts (1 hunks)
  • packages/trpc/server/routers/viewer/availability/schedule/update.schema.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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/trpc/server/routers/viewer/availability/schedule/create.schema.ts
  • packages/trpc/server/routers/viewer/availability/schedule/update.schema.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/trpc/server/routers/viewer/availability/schedule/create.schema.ts
  • packages/trpc/server/routers/viewer/availability/schedule/update.schema.ts
**/*.{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/trpc/server/routers/viewer/availability/schedule/create.schema.ts
  • packages/trpc/server/routers/viewer/availability/schedule/update.schema.ts
🔇 Additional comments (1)
packages/trpc/server/routers/viewer/availability/schedule/create.schema.ts (1)

4-4: LGTM! Required field validation is correct.

The validation properly enforces a non-empty trimmed name for schedule creation. Making the name field required (not optional) is appropriate for CREATE operations—every new schedule must have a name.

Copy link
Contributor

@pallava-joshi pallava-joshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the i18n translations bug. rest LGTM.

@pallava-joshi pallava-joshi marked this pull request as draft October 13, 2025 06:28
xDipzz added a commit to xDipzz/cal.com that referenced this pull request Nov 27, 2025
- Add frontend validation with error toast and i18n support
- Add backend validation with .trim().min(1) in Zod schemas
- Add i18n translation for schedule_name_cannot_be_empty
- Add comprehensive tests for create and update schemas (9 tests)
- Sync previousValue with prop changes in EditableHeading
- Follow PR calcom#24044 approach with all reviewer feedback addressed

Fixes calcom#21709
@github-actions github-actions bot added the Low priority Created by Linear-GitHub Sync label Jan 13, 2026
Copy link
Contributor

@anikdhabal anikdhabal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@anikdhabal anikdhabal dismissed stale reviews from volnei and pallava-joshi January 13, 2026 18:13

stale

@anikdhabal anikdhabal marked this pull request as ready for review January 13, 2026 18:13
@anikdhabal anikdhabal added the run-ci Approve CI to run for external contributors label Jan 13, 2026
@anikdhabal anikdhabal enabled auto-merge (squash) January 13, 2026 18:15
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="apps/web/modules/availability/[schedule]/schedule-view.tsx">

<violation number="1" location="apps/web/modules/availability/[schedule]/schedule-view.tsx:124">
P2: New translation key `schedule_name_cannot_be_empty` is only present in en locale; missing in other locales so non-English users will see untranslated toast</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@anikdhabal anikdhabal merged commit c13fce4 into calcom:main Jan 13, 2026
85 of 93 checks passed
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 community Created by Linear-GitHub Sync consumer Low priority Created by Linear-GitHub Sync ready-for-e2e run-ci Approve CI to run for external contributors size/XS ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Availability heading can set as empty

5 participants

Comments