Skip to content

Commit 3e2bab6

Browse files
committed
fix(monitoring): skip 4xx errors in handleError to silence bot 404 noise
Bot probes on /:username/:slug-like paths (e.g. /core/app/.env) were slipping through the allowlist as valid-looking routes. Root cause: SvelteKit handleError fires for all unhandled errors including 404s. Only 5xx errors are real server problems worth alerting on.
1 parent 5c1035f commit 3e2bab6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/hooks.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ function isMonitoredPath(pathname: string): boolean {
108108
return MONITORED_PATH_PATTERNS.some((p) => p.test(pathname));
109109
}
110110

111-
export const handleError: HandleServerError = async ({ error, event }) => {
111+
export const handleError: HandleServerError = async ({ error, event, status }) => {
112+
// Only report real server errors (5xx). 4xx (including 404 from bot probes) are not alertable.
113+
if (status < 500) return;
112114
if (!isMonitoredPath(event.url.pathname)) return;
113115
const dsn = event.platform?.env?.SENTRY_DSN;
114116
if (dsn) {

0 commit comments

Comments
 (0)