fix: remove console.log and improve type safety in tRPC routers (#29529)
- Remove two console.log statements dumping private hashed link data in update.handler.ts (fixes production data leakage) - Replace console.log(e) with structured logger.error in getScheduleByEventTypeSlug.handler.ts - Fix @ts-expect-error by typing reduce accumulator as Record<string, unknown> in update.handler.ts - Narrow Prisma include to select in duplicate.handler.ts: team and webhooks now fetch only required fields Fixes #29500 Co-authored-by: lucadapice <dapice.lc@gmail.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Bandhan Majumder <133476557+bandhan-majumder@users.noreply.github.com>
This commit is contained in:
co-authored by
lucadapice
Claude Sonnet 4.6
Bandhan Majumder
parent
4e529cbad1
commit
ebf696a991
+2
-1
@@ -1,5 +1,6 @@
|
||||
import type { PrismaClient } from "@calcom/prisma";
|
||||
|
||||
import logger from "@calcom/lib/logger";
|
||||
import type { TrpcSessionUser } from "../../../../types";
|
||||
import { getHandler } from "./get.handler";
|
||||
import type { TGetByEventSlugInputSchema } from "./getScheduleByEventTypeSlug.schema";
|
||||
@@ -57,7 +58,7 @@ export const getScheduleByEventSlugHandler = async ({ ctx, input }: GetOptions)
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
logger.error(e);
|
||||
return {
|
||||
id: -1,
|
||||
name: "No schedules found",
|
||||
|
||||
@@ -39,8 +39,16 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
|
||||
},
|
||||
},
|
||||
hosts: true,
|
||||
team: true,
|
||||
webhooks: true,
|
||||
team: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
webhooks: {
|
||||
select: {
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
hashedLink: true,
|
||||
destinationCalendar: true,
|
||||
calVideoSettings: {
|
||||
|
||||
@@ -608,11 +608,9 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log("multiplePrivateLinks", multiplePrivateLinks);
|
||||
// Handle multiple private links using the service
|
||||
const privateLinksRepo = HashedLinkRepository.create();
|
||||
const connectedLinks = await privateLinksRepo.findLinksByEventTypeId(input.id);
|
||||
console.log("connectedLinks", connectedLinks);
|
||||
const connectedMultiplePrivateLinks = connectedLinks.map((link) => link.link);
|
||||
|
||||
const privateLinksService = new HashedLinkService();
|
||||
@@ -724,9 +722,8 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
|
||||
});
|
||||
}
|
||||
|
||||
const updatedValues = Object.entries(data).reduce((acc, [key, value]) => {
|
||||
const updatedValues = Object.entries(data).reduce<Record<string, unknown>>((acc, [key, value]) => {
|
||||
if (value !== undefined) {
|
||||
// @ts-expect-error Element implicitly has any type
|
||||
acc[key] = value;
|
||||
}
|
||||
return acc;
|
||||
|
||||
Reference in New Issue
Block a user