Skip to content

fix: check team existence before parsing metadata#29466

Open
pranavv00 wants to merge 1 commit into
calcom:mainfrom
pranavv00:fix/team-not-found-check
Open

fix: check team existence before parsing metadata#29466
pranavv00 wants to merge 1 commit into
calcom:mainfrom
pranavv00:fix/team-not-found-check

Conversation

@pranavv00
Copy link
Copy Markdown
Contributor

Summary

Fixes #29457 by checking whether the team exists before parsing metadata.

Changes

  • Move the if (!team) check before metadata parsing
  • Update error message from "user not found" to "team not found"
  • Remove unnecessary optional chaining after the null guard

Result

Nonexistent teams now correctly throw a NotFoundException instead of a schema validation error.

…pp (calcom#29457)

teamMetadataSchema.parse(team?.metadata) was called before checking
if team exists, causing a Zod validation error on undefined instead
of the intended NotFoundException. Also corrected the misleading
error message from 'user not found' to 'team not found'.
@github-actions github-actions Bot added the 🐛 bug Something isn't working label May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @pranavv00! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bf9bfbf3-dd3c-4841-8410-f9fd1ecda595

📥 Commits

Reviewing files that changed from the base of the PR and between 180ede2 and 03b704c.

📒 Files selected for processing (1)
  • apps/api/v2/src/modules/teams/teams/teams.repository.ts

📝 Walkthrough

Walkthrough

This pull request fixes the setDefaultConferencingApp method in the teams repository. The method now validates that the requested team exists before attempting to access its metadata. If the team does not exist, it throws a NotFoundException with the correct error message ("team not found" instead of the previous "user not found"). The change also removes optional chaining on team?.metadata, allowing the metadata schema validator to operate on a guaranteed non-null object.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving the team existence check before metadata parsing.
Description check ✅ Passed The description is related to the changeset, providing clear summary, changes, and expected result of the fix.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #29457: null check moved before metadata parsing [#29457], error message corrected [#29457], and optional chaining removed [#29457].
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the identified issue with team existence validation and error handling; no extraneous modifications are present.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 8, 2026

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions Bot added the Stale label Jun 8, 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/XS Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOW: setDefaultConferencingApp parses metadata before checking if the team exists

1 participant