Skip to content

fix: event api accepts invalid start & end values#13203

Merged
keithwillcode merged 6 commits intocalcom:mainfrom
MehulZR:fix_event_api
Jan 20, 2024
Merged

fix: event api accepts invalid start & end values#13203
keithwillcode merged 6 commits intocalcom:mainfrom
MehulZR:fix_event_api

Conversation

@MehulZR
Copy link
Copy Markdown
Contributor

@MehulZR MehulZR commented Jan 12, 2024

What does this PR do?

Fixes #13086 (issue)

Before.mp4
After.mp4

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 12, 2024

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

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 12, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@github-actions github-actions bot added api area: API, enterprise API, access token, OAuth Medium priority Created by Linear-GitHub Sync 🐛 bug Something isn't working labels Jan 12, 2024
@MehulZR
Copy link
Copy Markdown
Contributor Author

MehulZR commented Jan 12, 2024

I have looked only a couple of tests, its looks like tests are containing invalid end values. Will look more into it tomorrow.

Such Code Reference
            await createBookingScenario(
              getScenarioData({
                webhooks: [
                  {
                    userId: organizer.id,
                    eventTriggers: ["BOOKING_CREATED"],
                    subscriberUrl: "http://my-webhook.example.com",
                    active: true,
                    eventTypeId: 1,
                    appId: null,
                  },
                ],
                eventTypes: [
                  {
                    id: 1,
                    slotInterval: 45,
                    schedulingType: SchedulingType.COLLECTIVE,
                    length: 45,
                    users: [
                      {
                        id: 101,
                      },
                      {
                        id: 102,
                      },
                    ],
                    destinationCalendar: {
                      integration: TestData.apps["google-calendar"].type,
                      externalId: "event-type-1@google-calendar.com",
                    },
                  },
                ],
                organizer,
                usersApartFromOrganizer: otherTeamMembers,
                apps: [TestData.apps["google-calendar"], TestData.apps["daily-video"]],
              })
            );

            mockSuccessfulVideoMeetingCreation({
              metadataLookupKey: appStoreMetadata.dailyvideo.dirName,
              videoMeetingData: {
                id: "MOCK_ID",
                password: "MOCK_PASS",
                url: `http://mock-dailyvideo.example.com/meeting-1`,
              },
            });

            const calendarMock = mockCalendarToHaveNoBusySlots("googlecalendar", {
              create: {
                id: "MOCKED_GOOGLE_CALENDAR_EVENT_ID",
                iCalUID: "MOCKED_GOOGLE_CALENDAR_ICS_ID",
              },
            });

            const mockBookingData = getMockRequestDataForBooking({
              data: {
                // Try booking the first available free timeslot in both the users' schedules
                start: `${getDate({ dateIncrement: 1 }).dateString}T11:30:00.000Z`,
                end: `${getDate({ dateIncrement: 1 }).dateString}T11:45:00.000Z`,
                eventTypeId: 1,
                responses: {
                  email: booker.email,
                  name: booker.name,
                  location: { optionValue: "", value: BookingLocations.CalVideo },
                },
              },
            });

            const { req } = createMockNextJsRequest({
              method: "POST",
              body: mockBookingData,
            });

            const createdBooking = await handleNewBooking(req);

@keithwillcode keithwillcode added the community Created by Linear-GitHub Sync label Jan 14, 2024
@keithwillcode keithwillcode self-assigned this Jan 14, 2024
@keithwillcode keithwillcode added this to the v3.8 milestone Jan 14, 2024
@keithwillcode keithwillcode requested review from a team and keithwillcode January 15, 2024 09:47
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 18, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

One Page Changed Size

The following page changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/availability/troubleshoot 272.8 KB 438.86 KB 125.39% (🔴 +29.34%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

Copy link
Copy Markdown
Contributor

@zomars zomars left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution 🙏 Would you mind a unit test where we expect it to fail?

Something like "expected 30, sent 15 and expects an error"

@MehulZR
Copy link
Copy Markdown
Contributor Author

MehulZR commented Jan 20, 2024

Thank you for your contribution 🙏 Would you mind a unit test where we expect it to fail?

Something like "expected 30, sent 15 and expects an error"

Sure.

@keithwillcode keithwillcode enabled auto-merge (squash) January 20, 2024 17:27
@keithwillcode keithwillcode merged commit 95e037c into calcom:main Jan 20, 2024
@MehulZR MehulZR deleted the fix_event_api branch February 17, 2024 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth 🐛 bug Something isn't working community Created by Linear-GitHub Sync Medium priority Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Book event api is accepting invalid start end values

3 participants