From 699464c9abfb053c9845150cbcb86cd8f36a51b3 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Wed, 22 Jul 2026 22:38:26 +0000 Subject: [PATCH 1/2] fix(cli): Allow '=' as key-value separator for tags and extra flags --- src/lib/envelope/event-builder.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/envelope/event-builder.ts b/src/lib/envelope/event-builder.ts index 0e45d6923f..32f1dba33e 100644 --- a/src/lib/envelope/event-builder.ts +++ b/src/lib/envelope/event-builder.ts @@ -40,7 +40,10 @@ const KNOWN_USER_FIELDS = new Set(["id", "email", "ip_address", "username"]); * Throws ValidationError if the format is wrong. */ export function parseKeyValue(pair: string): [string, string] { - const idx = pair.indexOf(":"); + const colonIdx = pair.indexOf(":"); + const equalsIdx = pair.indexOf("="); + const candidates = [colonIdx, equalsIdx].filter((i) => i > 0); + const idx = candidates.length > 0 ? Math.min(...candidates) : -1; if (idx <= 0) { throw new ValidationError( `Expected KEY:VALUE format, got: ${JSON.stringify(pair)}`, From debfb8597b0c09580bc5021d8d9fffbb7b1dedb9 Mon Sep 17 00:00:00 2001 From: "jared-outpost[bot]" Date: Fri, 24 Jul 2026 22:09:45 +0000 Subject: [PATCH 2/2] fix(cli): reject key-value pairs with a leading separator parseKeyValue filtered colon/equals indices with i > 0 independently, so ':key=value' silently split at the '=' and produced a malformed key with a leading colon instead of rejecting it. Take the earliest of the two separators (i >= 0) and validate the final index with idx > 0 so a leading delimiter fails as before. --- src/lib/envelope/event-builder.ts | 9 +++++---- test/lib/envelope/event-builder.test.ts | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/lib/envelope/event-builder.ts b/src/lib/envelope/event-builder.ts index 32f1dba33e..8644f13e5c 100644 --- a/src/lib/envelope/event-builder.ts +++ b/src/lib/envelope/event-builder.ts @@ -34,16 +34,17 @@ export type SendEventFlags = { const KNOWN_USER_FIELDS = new Set(["id", "email", "ip_address", "username"]); /** - * Parse a single KEY:VALUE string, splitting on the first colon. + * Parse a single KEY:VALUE (or KEY=VALUE) string, splitting on the first + * `:` or `=`, whichever appears first. * - * Values may contain colons (e.g. `url:https://example.com`). + * Values may contain further separators (e.g. `url:https://example.com`). * Throws ValidationError if the format is wrong. */ export function parseKeyValue(pair: string): [string, string] { const colonIdx = pair.indexOf(":"); const equalsIdx = pair.indexOf("="); - const candidates = [colonIdx, equalsIdx].filter((i) => i > 0); - const idx = candidates.length > 0 ? Math.min(...candidates) : -1; + const found = [colonIdx, equalsIdx].filter((i) => i >= 0); + const idx = found.length > 0 ? Math.min(...found) : -1; if (idx <= 0) { throw new ValidationError( `Expected KEY:VALUE format, got: ${JSON.stringify(pair)}`, diff --git a/test/lib/envelope/event-builder.test.ts b/test/lib/envelope/event-builder.test.ts index ede470f1e1..4a6fb5aa11 100644 --- a/test/lib/envelope/event-builder.test.ts +++ b/test/lib/envelope/event-builder.test.ts @@ -35,6 +35,23 @@ describe("parseKeyValue", () => { test("empty key → throws ValidationError", async () => { expect(() => parseKeyValue(":value")).toThrow(ValidationError); }); + + test("splits on first equals sign", async () => { + expect(parseKeyValue("key=value")).toEqual(["key", "value"]); + }); + + test("splits on whichever separator comes first", async () => { + expect(parseKeyValue("key=a:b")).toEqual(["key", "a:b"]); + expect(parseKeyValue("key:a=b")).toEqual(["key", "a=b"]); + }); + + test("leading equals sign → throws ValidationError", async () => { + expect(() => parseKeyValue("=value")).toThrow(ValidationError); + }); + + test("leading colon before a later equals → throws ValidationError", async () => { + expect(() => parseKeyValue(":key=value")).toThrow(ValidationError); + }); }); // ── parseUserFields ───────────────────────────────────────────────