Skip to content

Commit 2efcfab

Browse files
Fix isEventTypeLoggingEnabled bug where empty string matches eventTypeId 0 (calcom#24804)
When BOOKING_LOGGING_EVENT_IDS is set to an empty string, the current implementation splits it into [''] and Number('') returns 0, causing any event type with ID 0 to incorrectly trigger debug logging. This fix: - Filters out empty/invalid event IDs (NaN, <=0) - Filters out empty usernames - Only matches valid, positive event type IDs Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 3c1dfe8 commit 2efcfab

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

packages/features/bookings/lib/isEventTypeLoggingEnabled.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ export function isEventTypeLoggingEnabled({
99
usernameOrTeamName instanceof Array ? usernameOrTeamName : [usernameOrTeamName];
1010
// eslint-disable-next-line turbo/no-undeclared-env-vars
1111
const bookingLoggingEventIds = process.env.BOOKING_LOGGING_EVENT_IDS || "";
12-
const isEnabled = bookingLoggingEventIds.split(",").some((id) => {
13-
if (Number(id.trim()) === eventTypeId) {
14-
return true;
15-
}
16-
});
12+
const validEventIds = bookingLoggingEventIds
13+
.split(",")
14+
.map((id) => Number(id.trim()))
15+
.filter((id) => !isNaN(id) && id > 0);
16+
17+
const isEnabled = eventTypeId && validEventIds.includes(eventTypeId);
1718

1819
if (isEnabled) {
1920
return true;
2021
}
2122

2223
// eslint-disable-next-line turbo/no-undeclared-env-vars
2324
const bookingLoggingUsername = process.env.BOOKING_LOGGING_USER_OR_TEAM_NAME || "";
24-
return bookingLoggingUsername.split(",").some((u) => {
25-
return usernameOrTeamnamesList.some((foundUsername) => foundUsername === u.trim());
25+
const validUsernames = bookingLoggingUsername
26+
.split(",")
27+
.map((u) => u.trim())
28+
.filter((u) => u.length > 0);
29+
30+
return validUsernames.some((username) => {
31+
return usernameOrTeamnamesList.some((foundUsername) => foundUsername === username);
2632
});
2733
}

0 commit comments

Comments
 (0)