mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-07-21 21:13:45 +08:00
🐛 Ignore expected WhatsApp webhook errors (#2527)
- Added a viewer ORPC Sentry filter for expected production WhatsApp webhook validation failures. - Kept invalid webhook secret, signature, and payload responses flowing back to callers without reporting them to Sentry.
This commit is contained in:
parent
c82ac4324a
commit
3b321f4ba1
@ -11,6 +11,21 @@ const webhookUrlPaths = [
|
||||
"billingRouter/webhook",
|
||||
];
|
||||
|
||||
const expectedWhatsAppWebhookValidationErrors = [
|
||||
{
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Invalid WhatsApp webhook secret",
|
||||
},
|
||||
{
|
||||
code: "UNAUTHORIZED",
|
||||
message: "Invalid WhatsApp webhook signature",
|
||||
},
|
||||
{
|
||||
code: "BAD_REQUEST",
|
||||
message: "Invalid WhatsApp webhook payload",
|
||||
},
|
||||
];
|
||||
|
||||
const sentryMiddleware = os.middleware(async ({ next, path }) => {
|
||||
try {
|
||||
return await next();
|
||||
@ -34,6 +49,8 @@ const sentryMiddleware = os.middleware(async ({ next, path }) => {
|
||||
});
|
||||
|
||||
const isUnknownError = (error: unknown, path: string) => {
|
||||
if (isExpectedWhatsAppWebhookValidationError(error, path)) return false;
|
||||
|
||||
if (
|
||||
error instanceof ORPCError &&
|
||||
!error.code?.includes("INTERNAL_SERVER_ERROR") &&
|
||||
@ -44,6 +61,18 @@ const isUnknownError = (error: unknown, path: string) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const isExpectedWhatsAppWebhookValidationError = (
|
||||
error: unknown,
|
||||
path: string,
|
||||
) =>
|
||||
path === "chatWhatsAppRouter/productionWebhookProcedure" &&
|
||||
error instanceof ORPCError &&
|
||||
expectedWhatsAppWebhookValidationErrors.some(
|
||||
(expectedError) =>
|
||||
error.code === expectedError.code &&
|
||||
error.message === expectedError.message,
|
||||
);
|
||||
|
||||
const requireAuth = oo.spec(
|
||||
os.middleware(async ({ next, context }) => {
|
||||
const user = await context.authenticate();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user