fix: v2 sentry errors (#21214)

* fix: PATCH, POST event-types Address location must have an address

* fix: GET event-types Address location must have an address

* fix: POST /v2/bookings Address location must have an address

* refactor: GET /v2/slots Invalid time range given.

* fix: POST v2/event-types Cannot read properties of null (reading 'type')

* fix: POST /v2/bookings/:bookingUid/mark-absent Failed to update no-show status
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2025-05-14 10:11:35 +03:00
1 parent 39077a08f1
commit 1a70f83d34
8 files changed
+111 -51

No files matched your search

@@ -9,6 +9,7 @@ import type {
OutputLinkLocation_2024_06_14,
OutputPhoneLocation_2024_06_14,
OutputUnknownLocation_2024_06_14,
OutputLocation_2024_06_14,
} from "@calcom/platform-types";
import type { InternalLocation } from "../internal/locations";
@@ -50,64 +51,73 @@ export function transformLocationsInternalToApi(internalLocations: InternalLocat
return [];
}
return internalLocations.map((location) => {
const apiLocations: OutputLocation_2024_06_14[] = [];
for (const location of internalLocations) {
switch (location.type) {
case "inPerson": {
if (!location.address) {
throw new Error("Address location must have an address");
continue;
}
const addressLocation: OutputAddressLocation_2024_06_14 = {
type: "address",
address: location.address,
public: location.displayLocationPublicly,
};
return addressLocation;
apiLocations.push(addressLocation);
break;
}
case "attendeeInPerson": {
const attendeeAddressLocation: OutputAttendeeAddressLocation_2024_06_14 = {
type: "attendeeAddress",
};
return attendeeAddressLocation;
apiLocations.push(attendeeAddressLocation);
break;
}
case "link": {
if (!location.link) {
throw new Error("Link location must have a link");
continue;
}
const linkLocation: OutputLinkLocation_2024_06_14 = {
type: "link",
link: location.link,
public: location.displayLocationPublicly,
};
return linkLocation;
apiLocations.push(linkLocation);
break;
}
case "userPhone": {
if (!location.hostPhoneNumber) {
throw new Error("Phone location must have a phone number");
continue;
}
const phoneLocation: OutputPhoneLocation_2024_06_14 = {
type: "phone",
phone: location.hostPhoneNumber,
public: location.displayLocationPublicly,
};
return phoneLocation;
apiLocations.push(phoneLocation);
break;
}
case "phone": {
const attendeePhoneLocation: OutputAttendeePhoneLocation_2024_06_14 = {
type: "attendeePhone",
};
return attendeePhoneLocation;
apiLocations.push(attendeePhoneLocation);
break;
}
case "somewhereElse": {
const attendeeDefinedLocation: OutputAttendeeDefinedLocation_2024_06_14 = {
type: "attendeeDefined",
};
return attendeeDefinedLocation;
apiLocations.push(attendeeDefinedLocation);
break;
}
case "conferencing": {
const conferencingLocation: OutputOrganizersDefaultAppLocation_2024_06_14 = {
type: "organizersDefaultApp",
};
return conferencingLocation;
apiLocations.push(conferencingLocation);
break;
}
default: {
const integrationType = internalToApiIntegrationsMapping[location.type];
@@ -116,7 +126,8 @@ export function transformLocationsInternalToApi(internalLocations: InternalLocat
type: "unknown",
location: JSON.stringify(location),
};
return unknown;
apiLocations.push(unknown);
break;
}
const integration: OutputIntegrationLocation_2024_06_14 = {
type: "integration",
@@ -124,8 +135,11 @@ export function transformLocationsInternalToApi(internalLocations: InternalLocat
link: location.link,
credentialId: location.credentialId,
};
return integration;
apiLocations.push(integration);
break;
}
}
});
}
return apiLocations;
}
@@ -1,6 +1,6 @@
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
import { plainToInstance } from "class-transformer";
import { IsString, IsIn, IsPhoneNumber } from "class-validator";
import { IsString, IsIn, IsPhoneNumber, MinLength } from "class-validator";
import type { ValidationOptions, ValidatorConstraintInterface } from "class-validator";
import { registerDecorator, validate, ValidatorConstraint } from "class-validator";
@@ -104,6 +104,7 @@ export class BookingInputAttendeeAddressLocation_2024_08_13 {
type!: "attendeeAddress";
@IsString()
@MinLength(1)
@DocsProperty({ example: "123 Example St, City, Country" })
address!: string;
}
@@ -126,6 +127,7 @@ export class BookingInputAttendeeDefinedLocation_2024_08_13 {
type!: "attendeeDefined";
@IsString()
@MinLength(1)
@DocsProperty({ example: "321 Example St, City, Country" })
location!: string;
}
@@ -1,7 +1,7 @@
import { BadRequestException } from "@nestjs/common";
import { ApiProperty as DocsProperty } from "@nestjs/swagger";
import { plainToInstance } from "class-transformer";
import { IsString, IsUrl, IsIn, IsPhoneNumber, IsBoolean } from "class-validator";
import { IsString, IsUrl, IsIn, IsPhoneNumber, IsBoolean, MinLength } from "class-validator";
import type { ValidationOptions, ValidatorConstraintInterface } from "class-validator";
import { registerDecorator, validate, ValidatorConstraint } from "class-validator";
@@ -22,6 +22,7 @@ export class InputAddressLocation_2024_06_14 {
type!: "address";
@IsString()
@MinLength(1)
@DocsProperty({ example: "123 Example St, City, Country" })
address!: string;
@@ -136,6 +137,10 @@ class InputLocationValidator_2024_06_14 implements ValidatorConstraintInterface
}
for (const location of locations) {
if (!location || typeof location !== "object") {
throw new BadRequestException(`Each object in 'locations' must be an object.`);
}
const { type } = location;
if (!type) {
throw new BadRequestException(`Each object in 'locations' must have a 'type' property.`);
@@ -187,6 +192,10 @@ class InputTeamLocationValidator_2024_06_14 implements ValidatorConstraintInterf
}
for (const location of locations) {
if (!location || typeof location !== "object") {
throw new BadRequestException(`Each object in 'locations' must be an object.`);
}
const { type } = location;
if (!type) {
throw new BadRequestException(`Each object in 'locations' must have a 'type' property.`);
@@ -15,14 +15,14 @@ import {
import { SlotFormat } from "@calcom/platform-enums";
export class GetAvailableSlotsInput_2024_04_15 {
@IsDateString()
@IsDateString({ strict: true })
@ApiProperty({
description: "Start date string starting from which to fetch slots in UTC timezone.",
example: "2022-06-14T00:00:00.000Z",
})
startTime!: string;
@IsDateString()
@IsDateString({ strict: true })
@ApiProperty({
description: "End date string until which to fetch slots in UTC timezone.",
example: "2022-06-14T23:59:59.999Z",
@@ -14,7 +14,7 @@ import {
import { SlotFormat } from "@calcom/platform-enums";
export class GetAvailableSlotsInput_2024_09_04 {
@IsDateString()
@IsDateString({ strict: true })
@ApiProperty({
type: String,
description: `
@@ -29,7 +29,7 @@ export class GetAvailableSlotsInput_2024_09_04 {
})
start!: string;
@IsDateString()
@IsDateString({ strict: true })
@ApiProperty({
type: String,
description: `