From 4ca028cb4c0933136f0d517dd662990664c90d77 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 4 Aug 2026 15:43:18 +0200 Subject: [PATCH] [validation-tools] eventName: accept upper case letters (#36188) GitOrigin-RevId: 979ec5c744d5304232d447ff5fff076ee081721f --- .../validation-tools/test/unit/src/zodHelpers.test.ts | 8 +++++++- libraries/validation-tools/zodHelpers.js | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/validation-tools/test/unit/src/zodHelpers.test.ts b/libraries/validation-tools/test/unit/src/zodHelpers.test.ts index 1daef8b292..a859b4066c 100644 --- a/libraries/validation-tools/test/unit/src/zodHelpers.test.ts +++ b/libraries/validation-tools/test/unit/src/zodHelpers.test.ts @@ -781,7 +781,13 @@ describe('zodHelpers', () => { expect(parsed.data).toBe('editor-click_something-2') }) - it('fails to parse a name containing an uppercase letter or dots, colons, semicolons, commas and slashes', () => { + it('parses successfully when provided a name with upper case letter', () => { + const parsed = zz.eventName().safeParse('For-Pages') + expect(parsed.success).toBe(true) + expect(parsed.data).toBe('For-Pages') + }) + + it('fails to parse a name containing dots, colons, semicolons, commas and slashes', () => { const parsed = zz.eventName().safeParse('I.did:something,here/now;too') expect(parsed.success).toBe(false) expect(parsed.error?.issues).toMatchObject([ diff --git a/libraries/validation-tools/zodHelpers.js b/libraries/validation-tools/zodHelpers.js index 245616890b..d6ea8d5a9b 100644 --- a/libraries/validation-tools/zodHelpers.js +++ b/libraries/validation-tools/zodHelpers.js @@ -194,7 +194,7 @@ const zz = { * call site of recordEventForSession/recordEventForUser/ * recordEventForMongoUser in web's app/, modules/ and scripts/ -- is * already kebab-case or snake_case, i.e. already matches - * `^[a-z0-9-_]+$`. Capped at 240 characters, well above the longest of + * `/^[a-z0-9-_]+$/i`. Capped at 240 characters, well above the longest of * those literals. AnalyticsManager's own _isAttributeValid applies a * wider regex, but that's a separate, looser backend-only guard for call * sites that don't go through one of these schemas -- not evidence that a @@ -204,7 +204,7 @@ const zz = { z .string() .min(1, { message: 'invalid event name' }) - .regex(/^[a-z0-9-_]+$/, { message: 'invalid event name' }) + .regex(/^[a-zA-Z0-9-_]+$/, { message: 'invalid event name' }) .max(240, { message: 'event name is too long' }), /** * For endpoints that consume the request as a raw stream (e.g. blob