Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(web): drop Safari password-manager addMore.click from Sentry (#17263)

cursor[bot]493cf7d13f96
diff --git a/web/src/utils/sentryFilters.clienttest.ts b/web/src/utils/sentryFilters.clienttest.ts
index 267b58caef..c5c69c22ad 100644
--- a/web/src/utils/sentryFilters.clienttest.ts
+++ b/web/src/utils/sentryFilters.clienttest.ts
@@ -1043,6 +1043,87 @@ describe("isDenylistedNoiseEvent", () => {
});
});
+ describe("K. drops Safari password-manager addMore.click (document-attributed)", () => {
+ // Real shape: Safari 26.5 on settings API keys. Injected
+ // password-manager / autofill JS does `addMore.click()` after a key is
+ // created. `addMore` is undefined. WebKit's TypeError includes the
+ // expression. Stack is document-attributed global code — no /_next/
+ // chunk — so denyUrls cannot match. Langfuse has no `addMore` identifier.
+ const safariAddMoreClickEvent = (
+ value: string,
+ mechanismType = "auto.browser.global_handlers.onerror",
+ frames?: { filename: string; function?: string }[],
+ ): ErrorEvent =>
+ ({
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value,
+ mechanism: { type: mechanismType, handled: false },
+ ...(frames
+ ? {
+ stacktrace: {
+ frames: frames.map((frame) => ({
+ filename: frame.filename,
+ function: frame.function ?? "?",
+ })),
+ },
+ }
+ : {}),
+ },
+ ],
+ },
+ }) as ErrorEvent;
+
+ it("drops the WebKit addMore.click TypeError", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ safariAddMoreClickEvent(
+ "undefined is not an object (evaluating 'addMore.click')",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the null WebKit variant and a trailing period", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ safariAddMoreClickEvent(
+ "null is not an object (evaluating 'addMore.click').",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the same wording with click()", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ safariAddMoreClickEvent(
+ "undefined is not an object (evaluating 'addMore.click()')",
+ ),
+ ),
+ ).toBe(true);
+ });
+
+ it("drops the same wording with document-attributed frames", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ safariAddMoreClickEvent(
+ "undefined is not an object (evaluating 'addMore.click')",
+ "auto.browser.global_handlers.onerror",
+ [
+ {
+ filename: "app:///project/example/settings/api-keys",
+ function: "global code",
+ },
+ ],
+ ),
+ ),
+ ).toBe(true);
+ });
+ });
+
// The heart of the safety contract: prove that real / similar-looking errors
// are NOT dropped. If any of these regress to `true`, a real bug would be
// hidden from Sentry.
@@ -1599,6 +1680,114 @@ describe("isDenylistedNoiseEvent", () => {
expect(isDenylistedNoiseEvent(event)).toBe(false);
});
+ it("keeps a longer app message that merely quotes addMore.click", () => {
+ const event = {
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value:
+ "Failed to copy secret: undefined is not an object (evaluating 'addMore.click')",
+ mechanism: {
+ type: "auto.browser.global_handlers.onerror",
+ handled: false,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(event)).toBe(false);
+ });
+
+ it("keeps a different WebKit evaluating TypeError", () => {
+ const event = {
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value: "undefined is not an object (evaluating 'foo.bar')",
+ mechanism: {
+ type: "auto.browser.global_handlers.onerror",
+ handled: false,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(event)).toBe(false);
+ });
+
+ it("keeps Chromium's generic undefined.click TypeError", () => {
+ const event = {
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value: "Cannot read properties of undefined (reading 'click')",
+ mechanism: {
+ type: "auto.browser.global_handlers.onerror",
+ handled: false,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(event)).toBe(false);
+ });
+
+ it("keeps an app-captured addMore.click TypeError (not a Sentry browser wrap)", () => {
+ expect(
+ isDenylistedNoiseEvent(
+ exceptionEvent(
+ "undefined is not an object (evaluating 'addMore.click')",
+ "TypeError",
+ ),
+ ),
+ ).toBe(false);
+ const consoleCaptured = {
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value: "undefined is not an object (evaluating 'addMore.click')",
+ mechanism: {
+ type: "auto.core.capture_console",
+ handled: true,
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(consoleCaptured)).toBe(false);
+ });
+
+ it("keeps the Safari addMore.click TypeError when a first-party chunk is on the stack", () => {
+ const event = {
+ exception: {
+ values: [
+ {
+ type: "TypeError",
+ value: "undefined is not an object (evaluating 'addMore.click')",
+ mechanism: {
+ type: "auto.browser.global_handlers.onerror",
+ handled: false,
+ },
+ stacktrace: {
+ frames: [
+ {
+ filename:
+ "https://us.cloud.langfuse.com/_next/static/chunks/pages/project/[projectId]/settings/[page]-abc.js",
+ function: "onClick",
+ },
+ ],
+ },
+ },
+ ],
+ },
+ } as ErrorEvent;
+ expect(isDenylistedNoiseEvent(event)).toBe(false);
+ });
+
it("keeps an event with no exception values", () => {
expect(
isDenylistedNoiseEvent({ message: "some message" } as ErrorEvent),
diff --git a/web/src/utils/sentryFilters.ts b/web/src/utils/sentryFilters.ts
index 0ee221e8be..42f84aa1ac 100644
--- a/web/src/utils/sentryFilters.ts
+++ b/web/src/utils/sentryFilters.ts
@@ -382,6 +382,42 @@ const CHROME_EXTENSION_PORT_MESSAGES: readonly string[] = [
const CHROMIUM_GETTER_ONLY_WINDOW_NEXT_DATA_MESSAGE =
"Cannot set property __NEXT_DATA__ of #<Window> which has only a getter";
+/**
+ * Safari / WebKit wording when injected password-manager or autofill JS
+ * does `addMore.click()` and `addMore` is undefined. WebKit uniquely
+ * includes the expression in the TypeError. Langfuse has no `addMore`
+ * identifier. Observed as a global-handler TypeError with
+ * document-attributed frames — `denyUrls` cannot match.
+ *
+ * Whole-message only. An app error that quotes the phrase is longer
+ * and is KEPT.
+ */
+const SAFARI_ADDMORE_CLICK_RE =
+ /^(?:undefined|null) is not an object \(evaluating 'addMore\.click(?:\(\))?'\)$/;
+
+/**
+ * Match {@link SAFARI_ADDMORE_CLICK_RE} without {@link coreMessage}.
+ * `coreMessage` strips a trailing `(…)` parenthetical — that clause *is*
+ * WebKit's signature here, so stripping it would miss the real event.
+ */
+function isSafariAddMoreClickMessage(value: string): boolean {
+ return SAFARI_ADDMORE_CLICK_RE.test(value.trim().replace(/\.$/, "").trim());
+}
+
+/**
+ * True when any stack frame is a first-party Next.js chunk. Used as a
+ * negative guard so a future first-party throw that happens to share
+ * WebKit's wording still reaches Sentry.
+ */
+function hasFirstPartyChunkFrame(event: ErrorEvent): boolean {
+ const frames = event.exception?.values?.[0]?.stacktrace?.frames;
+ if (!frames || frames.length === 0) return false;
+ return frames.some(
+ (frame) =>
+ typeof frame?.filename === "string" && frame.filename.includes("/_next/"),
+ );
+}
+
/**
* A `TRPCClientError` re-wraps its cause's message. Depending on capture path
* the Sentry `value` may be the bare cause message (`Failed to fetch`) or carry
@@ -636,8 +672,13 @@ export function isDenylistedNoiseEvent(event: ErrorEvent): boolean {
// no stack, `denyUrls` cannot match. Sibling message is the other
// documented lastError for a torn-down extension port.
//
- // Both are anchored to a Sentry browser-API / global-handler mechanism
- // so an app-captured exception that merely quotes the phrase is KEPT.
+ // Safari password-manager `addMore.click` is the same class: WebKit's
+ // exact TypeError for an injected `addMore` that is undefined. Stack is
+ // document-attributed global code, not a chunk.
+ //
+ // All three are anchored to a Sentry browser-API / global-handler
+ // mechanism so an app-captured exception that merely quotes the
+ // phrase is KEPT.
const mechanismType = exception?.mechanism?.type;
if (
typeof mechanismType === "string" &&
@@ -651,6 +692,13 @@ export function isDenylistedNoiseEvent(event: ErrorEvent): boolean {
) {
return true;
}
+ if (
+ exceptionType === "TypeError" &&
+ isSafariAddMoreClickMessage(exceptionValue) &&
+ !hasFirstPartyChunkFrame(event)
+ ) {
+ return true;
+ }
}
// Next.js App Router hydrates with