From 163c10c71e1a59253ea4caee25ec15d5fdc5c246 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:58:15 +0000 Subject: [PATCH 1/2] Bump nodemailer from 6.7.2 to 6.9.9 in /packages/worker Bumps [nodemailer](https://github.com/nodemailer/nodemailer) from 6.7.2 to 6.9.9. - [Release notes](https://github.com/nodemailer/nodemailer/releases) - [Changelog](https://github.com/nodemailer/nodemailer/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodemailer/nodemailer/compare/v6.7.2...v6.9.9) --- updated-dependencies: - dependency-name: nodemailer dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- packages/worker/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/worker/package.json b/packages/worker/package.json index 2e3200fda5..6c4cc6fe5b 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -63,7 +63,7 @@ "koa-useragent": "^4.1.0", "lodash": "4.17.21", "node-fetch": "2.6.7", - "nodemailer": "6.7.2", + "nodemailer": "6.9.9", "passport-google-oauth": "2.0.0", "passport-local": "1.0.0", "pouchdb": "7.3.0", From be0ff766f3bc0c3726e7ab14a4ec7f7dd0adb525 Mon Sep 17 00:00:00 2001 From: melohagan <101575380+melohagan@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:25:18 +0000 Subject: [PATCH 2/2] Chore/fix worker request error message (#12943) * Revert "Surface email error (#12837)" This reverts commit 2a24c8537857af19c99ceb48fe111c814a8f29c6. * Improve workerRequest error handling * update account portal * Fix typing * lint --- packages/account-portal | 2 +- .../server/src/utilities/workerRequests.ts | 26 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/account-portal b/packages/account-portal index 52f51dcfb9..cc12291732 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit 52f51dcfb96d3fe58c8cc7a905e7d733f7cd84c2 +Subproject commit cc12291732ee902dc832bc7d93cf2086ffdf0cff diff --git a/packages/server/src/utilities/workerRequests.ts b/packages/server/src/utilities/workerRequests.ts index 1604a724d2..69ce58c8a9 100644 --- a/packages/server/src/utilities/workerRequests.ts +++ b/packages/server/src/utilities/workerRequests.ts @@ -1,4 +1,4 @@ -import fetch from "node-fetch" +import { Response, default as fetch } from "node-fetch" import env from "../environment" import { checkSlashesInUrl } from "./index" import { @@ -40,25 +40,21 @@ export function request(ctx?: Ctx, request?: any) { } async function checkResponse( - response: any, + response: Response, errorMsg: string, { ctx }: { ctx?: Ctx } = {} ) { - if (response.status !== 200) { - let error - try { - error = await response.json() - if (!error.message) { - error = JSON.stringify(error) - } - } catch (err) { - error = await response.text() + if (response.status >= 300) { + let responseErrorMessage + if (response.headers.get("content-type")?.includes("json")) { + const error = await response.json() + responseErrorMessage = error.message ?? JSON.stringify(error) + } else { + responseErrorMessage = await response.text() } - const msg = `Unable to ${errorMsg} - ${ - error.message ? error.message : error - }` + const msg = `Unable to ${errorMsg} - ${responseErrorMessage}` if (ctx) { - ctx.throw(400, msg) + ctx.throw(msg, response.status) } else { throw msg }