From 009f91d1636560fe6c60182c0bcff3d413da2919 Mon Sep 17 00:00:00 2001 From: okxint <130782884+okxint@users.noreply.github.com> Date: Wed, 8 Jul 2026 23:31:41 +0530 Subject: [PATCH] fix(CalEventParser): skip null/undefined values in getUserFieldsResponses (#29703) When a booking question is optional and left unanswered, the field value stored in customInputs can be null. The previous guard only checked for empty strings, so null (and undefined) would coerce to the literal strings "null"/"undefined" inside the template literal, polluting calendar event descriptions. Fixes #29688 --- packages/lib/CalEventParser.test.ts | 31 ++++++++++++++++++++++++++++- packages/lib/CalEventParser.ts | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/lib/CalEventParser.test.ts b/packages/lib/CalEventParser.test.ts index 716584b71b..bf6a50f482 100644 --- a/packages/lib/CalEventParser.test.ts +++ b/packages/lib/CalEventParser.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; import type { CalendarEvent } from "@calcom/types/Calendar"; -import { getRichDescription } from "./CalEventParser"; +import { getRichDescription, getUserFieldsResponses } from "./CalEventParser"; describe("getRichDescription", () => { const t = ((key: string, _args?: Record) => key) as TFunction; @@ -85,3 +85,32 @@ describe("getRichDescription", () => { expect(description).toContain("who:"); }); }); + +describe("getUserFieldsResponses", () => { + const t = ((key: string) => key) as TFunction; + + it("does not render null values for unanswered optional booking questions", () => { + // When an optional booking question is left unanswered, customInputs may store null + // for that field. Before the fix, null coerced to the string "null" in the template + // literal, polluting the calendar event description. + const result = getUserFieldsResponses( + { customInputs: { "Phone Number": null, Name: "Alice" } }, + t + ); + + expect(result).not.toContain("null"); + expect(result).toContain("Name"); + expect(result).toContain("Alice"); + }); + + it("does not render empty string values for booking questions", () => { + const result = getUserFieldsResponses( + { customInputs: { "Phone Number": "", Name: "Bob" } }, + t + ); + + expect(result).not.toContain("Phone Number"); + expect(result).toContain("Name"); + expect(result).toContain("Bob"); + }); +}); diff --git a/packages/lib/CalEventParser.ts b/packages/lib/CalEventParser.ts index ae05ca01c3..c7388c3639 100644 --- a/packages/lib/CalEventParser.ts +++ b/packages/lib/CalEventParser.ts @@ -117,7 +117,7 @@ export const getUserFieldsResponses = ( const responsesString = Object.keys(labelValueMap) .map((key) => { if (!labelValueMap) return ""; - if (labelValueMap[key] !== "") { + if (labelValueMap[key] != null && labelValueMap[key] !== "") { return ` ${t(key)}: ${labelValueMap[key]}