Skip to content

fix(api-v2): enable editing phone-only event types#28870

Open
bandhan-majumder wants to merge 1 commit intocalcom:mainfrom
bandhan-majumder:fix-25430
Open

fix(api-v2): enable editing phone-only event types#28870
bandhan-majumder wants to merge 1 commit intocalcom:mainfrom
bandhan-majumder:fix-25430

Conversation

@bandhan-majumder
Copy link
Copy Markdown
Contributor

@bandhan-majumder bandhan-majumder commented Apr 13, 2026

What does this PR do?

Previously only email based event types were supported to be updated via API v2. But we also have phone-only options for event types. So, this PR reuses the existing function to check whether the booking fields of the event has either phone/email or not. Includes relevant test updates as well.

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

after.mp4

Image Demo (if applicable):

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

How should this be tested?

Create an event type and go to the advanced tab and disable email. Enable phone and click save.
Get a api key
Now query the endpoint http://localhost:5555/v2/event-types/{eventTypeId} to update event type with the following headers

Authorization: api_key
cal-api-version: 2024-06-14
Content-Type: application/json

and this body:

{
  "bookingFields": [
    {
      "type": "email",
      "required": false,
      "hidden": true
    },
    {
      "type": "phone",
      "slug": "attendeePhoneNumber",
      "required": true,
      "hidden": false,
      "label": "Phone Number"
    },
    {
  "name": "name",
  "type": "name",
  "label": "your name",
  "sources": [
    {
      "id": "default",
      "type": "default",
      "label": "Default"
    }
  ],
  "variant": "fullName",
  "editable": "system",
  "required": true,
  "defaultLabel": "your_name",
  "variantsConfig": {
    "variants": {
      "fullName": {
        "fields": [
          {
            "name": "fullName",
            "type": "text",
            "label": "your name",
            "required": true
          }
        ]
      }
    }
  }
}
  ]
}
  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings
  • My PR is too large (>500 lines or >10 files) and should be split into smaller PRs

@bandhan-majumder bandhan-majumder requested review from a team as code owners April 13, 2026 17:07
@github-actions github-actions bot added Stale 🐛 bug Something isn't working labels Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

The PR modifies booking field validation for event types across multiple modules. A local validation method is replaced with a shared library validation function (ensureEmailOrPhoneNumberIsPresent) that is exported from the platform libraries package. End-to-end test cases in user and team event type controllers are updated to reflect new expectations, including successful creation of phone-only event types and updated validation error messages when both email and phone fields are hidden.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(api-v2): enable editing phone-only event types' directly and clearly describes the main change - enabling phone-only event type editing via API v2, which is the core purpose of this PR.
Description check ✅ Passed The description clearly relates to the changeset, explaining the motivation (supporting phone-only event types), the implementation approach (reusing an existing function), and includes links to related issues, testing instructions, and demo materials.
Linked Issues check ✅ Passed The PR successfully addresses issue #25430 by replacing email-only validation with a more permissive check that accepts either phone or email booking fields, allowing phone-only event types to be updated via API.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of enabling phone-only event type editing. The modifications include service validation updates, test updates, and a library export addition - all necessary and in-scope for this fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

Copy link
Copy Markdown
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: 2

🧹 Nitpick comments (2)
apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts (1)

235-239: Use unique slugs in the new tests to avoid cross-test coupling.

Both new cases reuse "phone-coding-consultation". A unique slug per test makes the validation target deterministic.

Suggested fix
-        slug: "phone-coding-consultation",
+        slug: `phone-coding-consultation-${randomString()}`,
...
-        slug: "phone-coding-consultation",
+        slug: `phone-coding-consultation-hidden-${randomString()}`,

Also applies to: 283-286

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts`
around lines 235 - 239, The two tests that create phone-only event types (the
"should be able to create phone-only event type" it-block and the other it-block
reusing the same slug) reuse the slug "phone-coding-consultation" which can
cause cross-test coupling; update each CreateTeamEventTypeInput_2024_06_14.slug
to a unique value per test (e.g., add a distinct suffix or index) so each test
targets a deterministic, independent slug and avoids interference between test
runs.
apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts (1)

374-375: Prefer unique slugs for the new phone-only tests.

Using the same fixed slug in both tests adds avoidable coupling and can obscure the real failure reason.

Suggested fix
-        slug: "phone-coding-consultation",
+        slug: `phone-coding-consultation-${randomString()}`,
...
-        slug: "phone-coding-consultation",
+        slug: `phone-coding-consultation-hidden-${randomString()}`,

Also applies to: 411-412

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts`
around lines 374 - 375, Replace the duplicated slug "phone-coding-consultation"
used in the two phone-only test fixtures with distinct values (e.g.,
"phone-coding-consultation-1" and "phone-coding-consultation-2") so the tests do
not share the same identifier; locate the slug occurrences (the object
containing slug: "phone-coding-consultation" and description: "Our team will
review your codebase.") in the event-types.controller.e2e-spec.ts phone-only
tests, update both slug strings to unique names, and also update any assertions
or lookups that reference that slug so they match the new unique values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts`:
- Around line 400-405: The test assertion for creating an event type is
expecting 200 but should expect 201; update the call in the spec that posts to
"/api/v2/event-types" (the request(...) chain using CAL_API_VERSION_HEADER,
VERSION_2024_06_14, apiKeyString, and body) to use .expect(201) instead of
.expect(200) so the create-endpoint contract matches the rest of the suite.

In
`@apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts`:
- Around line 276-280: The test is asserting a 200 on the POST to create an
event type but other tests and the API contract use 201 for successful creates;
update the assertion in the POST request to /v2/teams/${team.id}/event-types in
teams-event-types.controller.e2e-spec.ts (the request block that currently calls
.expect(200)) to .expect(201) so the test matches the create response code.

---

Nitpick comments:
In
`@apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts`:
- Around line 374-375: Replace the duplicated slug "phone-coding-consultation"
used in the two phone-only test fixtures with distinct values (e.g.,
"phone-coding-consultation-1" and "phone-coding-consultation-2") so the tests do
not share the same identifier; locate the slug occurrences (the object
containing slug: "phone-coding-consultation" and description: "Our team will
review your codebase.") in the event-types.controller.e2e-spec.ts phone-only
tests, update both slug strings to unique names, and also update any assertions
or lookups that reference that slug so they match the new unique values.

In
`@apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts`:
- Around line 235-239: The two tests that create phone-only event types (the
"should be able to create phone-only event type" it-block and the other it-block
reusing the same slug) reuse the slug "phone-coding-consultation" which can
cause cross-test coupling; update each CreateTeamEventTypeInput_2024_06_14.slug
to a unique value per test (e.g., add a distinct suffix or index) so each test
targets a deterministic, independent slug and avoids interference between test
runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0e77a48e-87a6-47c7-858d-f15a00469674

📥 Commits

Reviewing files that changed from the base of the PR and between 2911168 and b40b414.

📒 Files selected for processing (5)
  • apps/api/v2/src/ee/event-types/event-types_2024_06_14/controllers/event-types.controller.e2e-spec.ts
  • apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/event-types.service.ts
  • apps/api/v2/src/modules/teams/event-types/controllers/teams-event-types.controller.e2e-spec.ts
  • apps/api/v2/src/modules/teams/event-types/services/teams-event-types.service.ts
  • packages/platform/libraries/event-types.ts

@bandhan-majumder
Copy link
Copy Markdown
Contributor Author

bandhan-majumder commented Apr 13, 2026

@Udit-takkar @supalarry can I please get a review?

@github-actions github-actions bot removed the Stale label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update event type endpoint fails when the email is not set as required and visible for phone confirmation calendars

1 participant