Skip to content

[CAL-925] fix: add null check for userSchedule.availability#7053

Merged
emrysal merged 1 commit intocalcom:mainfrom
ShaneMaglangit:fix/cal-925
Feb 13, 2023
Merged

[CAL-925] fix: add null check for userSchedule.availability#7053
emrysal merged 1 commit intocalcom:mainfrom
ShaneMaglangit:fix/cal-925

Conversation

@ShaneMaglangit
Copy link
Copy Markdown
Contributor

@ShaneMaglangit ShaneMaglangit commented Feb 11, 2023

What does this PR do?

Fixes #6708

This issue seems to appear when the user does not have any availability created.

  • Does not happen when using any of the pre-created accounts, even if all availability are removed.

Environment: Production

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't added tests that prove my fix is effective or that my feature works

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
ui ⬜️ Ignored (Inspect) Feb 11, 2023 at 8:54AM (UTC)

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 11, 2023

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

A member of the Team first needs to authorize it.

@ShaneMaglangit ShaneMaglangit changed the title fix: add null check for userSchedule.availability [CAL-925] fix: add null check for userSchedule.availability Feb 11, 2023
: {
...userSchedule,
availability: userSchedule.availability.map((a) => ({
availability: userSchedule?.availability.map((a) => ({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
availability: userSchedule?.availability.map((a) => ({
// FIXME: Default Schedule can be null if the user has no schedules at all
// - Create testcases & test through the behaviour in this edge case.
availability: userSchedule?.availability.map((a) => ({

@emrysal
Copy link
Copy Markdown
Contributor

emrysal commented Feb 13, 2023

Thank you for your contribution! I added a FIXME so we will come back to this later to handle the situation with no availability better; but this fixes the hard crash 👍

@emrysal emrysal merged commit d6594da into calcom:main Feb 13, 2023
@ShaneMaglangit ShaneMaglangit deleted the fix/cal-925 branch February 13, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-925] 500 on prod /api/trpc/viewer.public.slots.getSchedule

2 participants