fix: Handle invalid non-delegation credential in cron (#21270)
Co-authored-by: Benny Joo <[email protected]> Co-authored-by: Omar López <[email protected]>
This commit is contained in:
12 files changed
+795
-112
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
vi.mock("@calcom/lib/server/serviceAccountKey", async (importOriginal) => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const actual = await importOriginal<any>();
|
||||
return {
|
||||
...actual,
|
||||
decryptServiceAccountKey: vi.fn((input) => {
|
||||
// If input is a string, parse it; otherwise, return as is
|
||||
if (typeof input === "string") {
|
||||
try {
|
||||
return JSON.parse(input);
|
||||
} catch {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
return input;
|
||||
}),
|
||||
};
|
||||
});
|
||||
@@ -67,7 +67,9 @@ export class SelectedCalendarRepository {
|
||||
const conflictingCalendar = await SelectedCalendarRepository.findConflicting(data);
|
||||
|
||||
if (conflictingCalendar) {
|
||||
throw new Error("Selected calendar already exists");
|
||||
throw new Error(
|
||||
`Selected calendar already exists for userId: ${data.userId}, integration: ${data.integration}, externalId: ${data.externalId}, eventTypeId: ${data.eventTypeId}`
|
||||
);
|
||||
}
|
||||
|
||||
return await prisma.selectedCalendar.create({
|
||||
@@ -125,6 +127,14 @@ export class SelectedCalendarRepository {
|
||||
});
|
||||
}
|
||||
|
||||
static async deleteById({ id }: { id: string }) {
|
||||
return await prisma.selectedCalendar.delete({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
static async createIfNotExists(data: Prisma.SelectedCalendarUncheckedCreateInput) {
|
||||
const conflictingCalendar = await SelectedCalendarRepository.findConflicting(data);
|
||||
|
||||
|
||||
Reference in new issue
Block a user