From 16e293a9ff5919d7b077ef4f726d8bd0259b8f57 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Thu, 4 Jul 2024 09:55:36 +0100 Subject: [PATCH] Fix tests. --- packages/backend-core/src/middleware/errorHandling.ts | 10 +++++----- packages/backend-core/src/security/secrets.ts | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/backend-core/src/middleware/errorHandling.ts b/packages/backend-core/src/middleware/errorHandling.ts index 3f6d069337..6ceda9cd3a 100644 --- a/packages/backend-core/src/middleware/errorHandling.ts +++ b/packages/backend-core/src/middleware/errorHandling.ts @@ -23,11 +23,6 @@ export async function errorHandling(ctx: any, next: any) { error: errors.getPublicError(err), } - if (environment.isTest() && ctx.headers["x-budibase-include-stacktrace"]) { - // @ts-ignore - error.stack = err.stack - } - if (stringContainsSecret(JSON.stringify(error))) { error = { message: "Unexpected error", @@ -36,6 +31,11 @@ export async function errorHandling(ctx: any, next: any) { } } + if (environment.isTest() && ctx.headers["x-budibase-include-stacktrace"]) { + // @ts-ignore + error.stack = err.stack + } + ctx.body = error } } diff --git a/packages/backend-core/src/security/secrets.ts b/packages/backend-core/src/security/secrets.ts index 65bc33a1dc..ab7ea36728 100644 --- a/packages/backend-core/src/security/secrets.ts +++ b/packages/backend-core/src/security/secrets.ts @@ -12,6 +12,7 @@ export function stringContainsSecret(str: string) { } if (str.includes(value)) { + throw new Error(`String contains secret: ${key}=${value}`) return true } }