From 27dec6e390251812fc55f940c3bbeb8c728f93a1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 10 Apr 2024 17:03:15 +0100 Subject: [PATCH 01/19] Update auth.ts --- packages/worker/src/api/controllers/global/auth.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/worker/src/api/controllers/global/auth.ts b/packages/worker/src/api/controllers/global/auth.ts index 86c90f9cd3..530a1df102 100644 --- a/packages/worker/src/api/controllers/global/auth.ts +++ b/packages/worker/src/api/controllers/global/auth.ts @@ -35,8 +35,7 @@ async function passportCallback( info: { message: string } | null = null ) { if (err) { - console.error("Authentication error") - console.error(err) + console.error("Authentication error", err) console.trace(err) return ctx.throw(403, info ? info : "Unauthorized") } From 639b8970f94653b2e7a45826aa0aa1a08e19ab14 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 10 Apr 2024 17:27:15 +0100 Subject: [PATCH 02/19] adding lint rule for console.error --- .eslintrc.json | 3 ++- eslint-local-rules/index.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 525072dc6c..fce6a9e27d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,7 +43,8 @@ "rules": { "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "error", - "local-rules/no-budibase-imports": "error" + "local-rules/no-budibase-imports": "error", + "local-rules/no-console-error": "error" } }, { diff --git a/eslint-local-rules/index.js b/eslint-local-rules/index.js index a4866bc1f8..d80aaf096d 100644 --- a/eslint-local-rules/index.js +++ b/eslint-local-rules/index.js @@ -1,4 +1,24 @@ module.exports = { + "no-console-error": { + create: function(context) { + return { + CallExpression(node) { + if ( + node.callee.type === "MemberExpression" && + node.callee.object.name === "console" && + node.callee.property.name === "error" && + node.arguments.length === 1 && + node.arguments[0].name.startsWith("err") + ) { + context.report({ + node, + message: 'Using console.error(err) on its own is not allowed. Either provide context to the error (console.error(msg, err)) or throw it.', + }) + } + }, + }; + }, + }, "no-budibase-imports": { create: function (context) { return { From 4a6e1b7192a6f3973232125e00191984945b6405 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Wed, 10 Apr 2024 17:39:12 +0100 Subject: [PATCH 03/19] fix all cases of lint rule --- eslint-local-rules/index.js | 1 + packages/backend-core/src/auth/auth.ts | 2 -- packages/backend-core/src/middleware/authenticated.ts | 2 -- packages/backend-core/src/middleware/errorHandling.ts | 2 +- packages/backend-core/src/middleware/passport/sso/google.ts | 1 - packages/backend-core/src/middleware/passport/sso/oidc.ts | 2 -- packages/backend-core/src/migrations/migrations.ts | 1 - packages/server/specs/generate.ts | 2 +- packages/server/src/integrations/oracle.ts | 2 +- packages/server/src/utilities/fileSystem/filesystem.ts | 2 +- 10 files changed, 5 insertions(+), 12 deletions(-) diff --git a/eslint-local-rules/index.js b/eslint-local-rules/index.js index d80aaf096d..e88642c905 100644 --- a/eslint-local-rules/index.js +++ b/eslint-local-rules/index.js @@ -8,6 +8,7 @@ module.exports = { node.callee.object.name === "console" && node.callee.property.name === "error" && node.arguments.length === 1 && + node.arguments[0].name && node.arguments[0].name.startsWith("err") ) { context.report({ diff --git a/packages/backend-core/src/auth/auth.ts b/packages/backend-core/src/auth/auth.ts index 87ac46cf1c..098e874863 100644 --- a/packages/backend-core/src/auth/auth.ts +++ b/packages/backend-core/src/auth/auth.ts @@ -64,7 +64,6 @@ async function refreshOIDCAccessToken( } strategy = await oidc.strategyFactory(enrichedConfig, ssoSaveUserNoOp) } catch (err) { - console.error(err) throw new Error("Could not refresh OAuth Token") } @@ -99,7 +98,6 @@ async function refreshGoogleAccessToken( ssoSaveUserNoOp ) } catch (err: any) { - console.error(err) throw new Error( `Error constructing OIDC refresh strategy: message=${err.message}` ) diff --git a/packages/backend-core/src/middleware/authenticated.ts b/packages/backend-core/src/middleware/authenticated.ts index d357dbdbdc..69dba27c43 100644 --- a/packages/backend-core/src/middleware/authenticated.ts +++ b/packages/backend-core/src/middleware/authenticated.ts @@ -138,7 +138,6 @@ export default function ( } catch (err: any) { authenticated = false console.error(`Auth Error: ${err.message}`) - console.error(err) // remove the cookie as the user does not exist anymore clearCookie(ctx, Cookie.Auth) } @@ -187,7 +186,6 @@ export default function ( } } catch (err: any) { console.error(`Auth Error: ${err.message}`) - console.error(err) // invalid token, clear the cookie if (err?.name === "JsonWebTokenError") { clearCookie(ctx, Cookie.Auth) diff --git a/packages/backend-core/src/middleware/errorHandling.ts b/packages/backend-core/src/middleware/errorHandling.ts index 2b8f7195ed..08f9f3214d 100644 --- a/packages/backend-core/src/middleware/errorHandling.ts +++ b/packages/backend-core/src/middleware/errorHandling.ts @@ -12,7 +12,7 @@ export async function errorHandling(ctx: any, next: any) { if (status >= 400 && status < 500) { console.warn(err) } else { - console.error(err) + console.error("Got 400 response code", err) } let error: APIError = { diff --git a/packages/backend-core/src/middleware/passport/sso/google.ts b/packages/backend-core/src/middleware/passport/sso/google.ts index 2a08ad7665..37a043cf0b 100644 --- a/packages/backend-core/src/middleware/passport/sso/google.ts +++ b/packages/backend-core/src/middleware/passport/sso/google.ts @@ -68,7 +68,6 @@ export async function strategyFactory( verify ) } catch (err: any) { - console.error(err) throw new Error(`Error constructing google authentication strategy: ${err}`) } } diff --git a/packages/backend-core/src/middleware/passport/sso/oidc.ts b/packages/backend-core/src/middleware/passport/sso/oidc.ts index 061e0507aa..35e6ee9fb0 100644 --- a/packages/backend-core/src/middleware/passport/sso/oidc.ts +++ b/packages/backend-core/src/middleware/passport/sso/oidc.ts @@ -103,7 +103,6 @@ export async function strategyFactory( strategy.name = "oidc" return strategy } catch (err: any) { - console.error(err) throw new Error(`Error constructing OIDC authentication strategy - ${err}`) } } @@ -142,7 +141,6 @@ export async function fetchStrategyConfig( callbackURL: callbackUrl, } } catch (err) { - console.error(err) throw new Error( `Error constructing OIDC authentication configuration - ${err}` ) diff --git a/packages/backend-core/src/migrations/migrations.ts b/packages/backend-core/src/migrations/migrations.ts index 3f033b8cdb..fe6bc17386 100644 --- a/packages/backend-core/src/migrations/migrations.ts +++ b/packages/backend-core/src/migrations/migrations.ts @@ -26,7 +26,6 @@ export const getMigrationsDoc = async (db: any) => { if (err.status && err.status === 404) { return { _id: DocumentType.MIGRATIONS } } else { - console.error(err) throw err } } diff --git a/packages/server/specs/generate.ts b/packages/server/specs/generate.ts index ade667ea66..eea00f83aa 100644 --- a/packages/server/specs/generate.ts +++ b/packages/server/specs/generate.ts @@ -76,7 +76,7 @@ function writeFile(output: any, filename: string) { console.log(`Wrote spec to ${path}`) return path } catch (err) { - console.error(err) + console.error("Error writing spec file", err) } } diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index f6ec593f2f..8105edfef8 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -378,7 +378,7 @@ class OracleIntegration extends Sql implements DatasourcePlus { try { await connection.close() } catch (err) { - console.error(err) + console.error("Error connecting to Oracle", err) } } } diff --git a/packages/server/src/utilities/fileSystem/filesystem.ts b/packages/server/src/utilities/fileSystem/filesystem.ts index add587cdea..b0a67ac94e 100644 --- a/packages/server/src/utilities/fileSystem/filesystem.ts +++ b/packages/server/src/utilities/fileSystem/filesystem.ts @@ -43,7 +43,7 @@ export const checkDevelopmentEnvironment = () => { error = "Must run via yarn once to generate environment." } if (error) { - console.error(error) + console.error("Error during development environment check", error) process.exit(-1) } } From c2cd2d4e61090358a0601806ecff83791b64fb59 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 11 Apr 2024 16:00:30 +0100 Subject: [PATCH 04/19] account portal submodule --- packages/account-portal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/account-portal b/packages/account-portal index a0ee9cad8c..bd0e01d639 160000 --- a/packages/account-portal +++ b/packages/account-portal @@ -1 +1 @@ -Subproject commit a0ee9cad8cefb8f9f40228705711be174f018fa9 +Subproject commit bd0e01d639ec3b2547e7c859a1c43b622dce8344 From 3cdc0525c61758c621a9f380a416c8f91990496e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 15 Apr 2024 15:29:11 +0100 Subject: [PATCH 05/19] Fix crashing when swapping conditional UI settings between invalid value types --- .../_components/Component/ConditionalUIDrawer.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ConditionalUIDrawer.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ConditionalUIDrawer.svelte index 23e7bced93..6558ba9dc2 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ConditionalUIDrawer.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/[componentId]/_components/Component/ConditionalUIDrawer.svelte @@ -189,6 +189,7 @@