From 599c265530029223a6adc5fd77ea9276ac7d6f14 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Thu, 21 Nov 2024 03:40:59 -0600 Subject: [PATCH] make sanitization failures permanent Signed-off-by: eternal-flame-AD --- packages/backend/src/core/activitypub/type.ts | 9 +++++---- .../src/queue/processors/InboxProcessorService.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/activitypub/type.ts b/packages/backend/src/core/activitypub/type.ts index c42a1b4769..c14c6aa55f 100644 --- a/packages/backend/src/core/activitypub/type.ts +++ b/packages/backend/src/core/activitypub/type.ts @@ -5,6 +5,7 @@ import { target } from "happy-dom/lib/PropertySymbol.js"; import { toASCII } from "node:punycode"; +import * as bull from "bullmq"; export type Obj = { [x: string]: any }; export type ApObject = IObject | string | (IObject | string)[]; @@ -81,11 +82,11 @@ export function yumeNormalizeURL(url: string): string { u.hash = ''; u.host = toASCII(u.host); if (u.protocol && u.protocol !== 'https:') { - throw new Error('protocol is not https'); + throw new bull.UnrecoverableError('protocol is not https'); } u.protocol = 'https:'; if (u.port && u.port !== '443') { - throw new Error('port is not 443'); + throw new bull.UnrecoverableError('port is not 443'); } return u.toString(); } @@ -93,7 +94,7 @@ export function yumeNormalizeURL(url: string): string { export function yumeNormalizeRecursive(object: O, depth = 0): IObject | string | (IObject | string)[] { if (depth > 16) { - throw new Error('recursion limit exceeded'); + throw new bull.UnrecoverableError('recursion limit exceeded'); } if (typeof object === 'string') { @@ -101,7 +102,7 @@ export function yumeNormalizeRecursive 64) { - throw new Error('array length limit exceeded'); + throw new bull.UnrecoverableError('array length limit exceeded'); } return object.flatMap(yumeNormalizeRecursive); } diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index ca7e4275de..8dbba7f51e 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -67,7 +67,7 @@ const mIncomingApReject = metricCounter({ const mincomingApProcessingError = metricCounter({ name: 'misskey_incoming_ap_processing_error', help: 'Incoming AP processing error', - labelNames: ['incoming_host', 'incoming_type', 'reason'], + labelNames: ['incoming_host', 'incoming_type'], }); @Injectable() @@ -307,7 +307,7 @@ export class InboxProcessorService implements OnApplicationShutdown { } const end = +new Date(); observeHistogram(mIncomingApProcessingTime, { success: 'false' }, (end - begin) / 1000); - incCounter(mincomingApProcessingError, { reason: 'unknown' }); + incCounter(mincomingApProcessingError, {}); throw e; } observeHistogram(mIncomingApProcessingTime, { success: 'true' }, (+new Date() - begin) / 1000);