diff --git a/pm-stack/aggregator/src/model.ts b/pm-stack/aggregator/src/model.ts index e13ef49ca..721ae06a9 100644 --- a/pm-stack/aggregator/src/model.ts +++ b/pm-stack/aggregator/src/model.ts @@ -488,7 +488,10 @@ const GH_URL = /https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/(?:issues|pull)\/(\d+ /** Every GitHub issue/PR URL in a piece of text, as ref keys (deduplicated). */ export function refsInText(text: string): RefKey[] { const out = new Set(); - for (const m of text.matchAll(GH_URL)) out.add(`${m[1]}#${m[2]}`); + for (const m of text.matchAll(GH_URL)) { + const key = m[1] + "#" + m[2]; + if (isValidRef(key)) out.add(key); + } return [...out]; } diff --git a/pm-stack/aggregator/test/registry-hygiene-4284.test.ts b/pm-stack/aggregator/test/registry-hygiene-4284.test.ts index db0f99530..11d284036 100644 --- a/pm-stack/aggregator/test/registry-hygiene-4284.test.ts +++ b/pm-stack/aggregator/test/registry-hygiene-4284.test.ts @@ -109,4 +109,28 @@ describe("both producers still emit gate-accepted records (#4284)", () => { expect(isSessionRecord(fromLaunch)).toBe(true); expect(fromLaunch.taskRefs).toEqual([]); }); + + test("oversized URLs in session fields do not poison task refs (#4890)", () => { + const fromEntry = recordFromSessionEntry({ + sessionId: "ses_oversized_refs", + source: "opencode-sandbox", + title: + "bad https://github.com/developing-today/code/issues/99999999999999999999 " + + "good https://github.com/developing-today/code/issues/123", + pr: + "bad https://github.com/developing-today/code/pull/9007199254740992 " + + "good https://github.com/developing-today/code/pull/124", + branch: + "bad https://github.com/developing-today/code/issues/99999999999999999999 " + + "good https://github.com/developing-today/code/pull/125", + lastActivityAt: "2026-11-02T00:00:00Z", + }); + + expect(fromEntry.taskRefs.sort()).toEqual([ + "developing-today/code#123", + "developing-today/code#124", + "developing-today/code#125", + ]); + expect(isSessionRecord(fromEntry)).toBe(true); + }); }); diff --git a/pm-stack/aggregator/test/render.test.ts b/pm-stack/aggregator/test/render.test.ts index 3e656c6ec..494360b28 100644 --- a/pm-stack/aggregator/test/render.test.ts +++ b/pm-stack/aggregator/test/render.test.ts @@ -61,6 +61,14 @@ describe("ref parsing", () => { ); expect(refs.sort()).toEqual(["developing-today/code#752", "dezren39/nix#501"].sort()); }); + test("skips URLs with unsafe numbers while keeping valid refs", () => { + const refs = refsInText( + "bad https://github.com/developing-today/code/issues/99999999999999999999 " + + "bad https://github.com/developing-today/code/pull/9007199254740992 " + + "good https://github.com/developing-today/code/issues/123", + ); + expect(refs).toEqual(["developing-today/code#123"]); + }); test("refUrl builds issue vs pr paths", () => { expect(refUrl("developing-today/code#752", "pr")).toBe("https://github.com/developing-today/code/pull/752"); expect(refUrl("developing-today/code#752")).toBe("https://github.com/developing-today/code/issues/752");