From 2e33680e6b1bf14d88e9a369ea34dab44dd6ec82 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 3 Jul 2024 09:19:19 +0100 Subject: [PATCH 1/4] Update MongoDB. --- packages/server/package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 94bbb6fc6b..a1f908aa80 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -94,7 +94,7 @@ "koa2-ratelimit": "1.1.1", "lodash": "4.17.21", "memorystream": "0.3.1", - "mongodb": "^6.3.0", + "mongodb": "^6.8.0", "mssql": "10.0.1", "mysql2": "3.9.8", "node-fetch": "2.6.7", diff --git a/yarn.lock b/yarn.lock index 542847053d..21eb381181 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3636,10 +3636,10 @@ semver "^7.3.5" tar "^6.1.11" -"@mongodb-js/saslprep@^1.1.0": - version "1.1.4" - resolved "https://registry.yarnpkg.com/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz#24ec1c4915a65f5c506bb88c081731450d91bb1c" - integrity sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw== +"@mongodb-js/saslprep@^1.1.5": + version "1.1.7" + resolved "https://registry.yarnpkg.com/@mongodb-js/saslprep/-/saslprep-1.1.7.tgz#d1700facfd6916c50c2c88fd6d48d363a56c702f" + integrity sha512-dCHW/oEX0KJ4NjDULBo3JiOaK5+6axtpBbS+ao2ZInoAL9/YRQLhXzSNAFz7hP4nzLkIqsfYAK/PDE3+XHny0Q== dependencies: sparse-bitfield "^3.0.3" @@ -8001,10 +8001,10 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -bson@^6.2.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/bson/-/bson-6.3.0.tgz#d47acba525ba7d7eb0e816c10538bce26a337fe0" - integrity sha512-balJfqwwTBddxfnidJZagCBPP/f48zj9Sdp3OJswREOgsJzHiQSaOIAtApSgDQFYgHqAvFkp53AFSqjMDZoTFw== +bson@^6.7.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/bson/-/bson-6.8.0.tgz#5063c41ba2437c2b8ff851b50d9e36cb7aaa7525" + integrity sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ== btoa@^1.2.1: version "1.2.1" @@ -16112,13 +16112,13 @@ mongodb-connection-string-url@^3.0.0: "@types/whatwg-url" "^11.0.2" whatwg-url "^13.0.0" -mongodb@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-6.3.0.tgz#ec9993b19f7ed2ea715b903fcac6171c9d1d38ca" - integrity sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA== +mongodb@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/mongodb/-/mongodb-6.8.0.tgz#680450f113cdea6d2d9f7121fe57cd29111fd2ce" + integrity sha512-HGQ9NWDle5WvwMnrvUxsFYPd3JEbqD3RgABHBQRuoCEND0qzhsd0iH5ypHsf1eJ+sXmvmyKpP+FLOKY8Il7jMw== dependencies: - "@mongodb-js/saslprep" "^1.1.0" - bson "^6.2.0" + "@mongodb-js/saslprep" "^1.1.5" + bson "^6.7.0" mongodb-connection-string-url "^3.0.0" ms@2.1.2: From 16cf99c3bc96f408f087f7847a0640d14c82d6a9 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 3 Jul 2024 08:28:11 +0000 Subject: [PATCH 2/4] Bump version to 2.29.7 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index e92bdb224b..6b36ce4849 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.29.6", + "version": "2.29.7", "npmClient": "yarn", "packages": [ "packages/*", From 9809bf1a918fe835d57d33af9f0434df54d1e864 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 3 Jul 2024 10:07:44 +0100 Subject: [PATCH 3/4] Fix an issue where null values were causing an error in automation loops (#14083) * fixes an issue where nulls weren't being handled correctly in loops * remove log * update recursive gate to be more specific * use lodash for object check --- packages/server/src/automations/loopUtils.ts | 11 ++- .../server/src/automations/tests/loop.spec.ts | 95 +++++++++++++++++++ 2 files changed, 105 insertions(+), 1 deletion(-) diff --git a/packages/server/src/automations/loopUtils.ts b/packages/server/src/automations/loopUtils.ts index 5ee2559050..9a8d2443d7 100644 --- a/packages/server/src/automations/loopUtils.ts +++ b/packages/server/src/automations/loopUtils.ts @@ -1,4 +1,5 @@ import * as automationUtils from "./automationUtils" +import { isPlainObject } from "lodash" type ObjValue = { [key: string]: string | ObjValue @@ -18,6 +19,10 @@ function replaceBindingsRecursive( value: string | ObjValue, loopStepNumber: number ) { + if (value === null || value === undefined) { + return value + } + if (typeof value === "object") { for (const [innerKey, innerValue] of Object.entries(value)) { if (typeof innerValue === "string") { @@ -25,7 +30,11 @@ function replaceBindingsRecursive( innerValue, `steps.${loopStepNumber}` ) - } else if (typeof innerValue === "object") { + } else if ( + innerValue && + isPlainObject(innerValue) && + Object.keys(innerValue).length > 0 + ) { value[innerKey] = replaceBindingsRecursive(innerValue, loopStepNumber) } } diff --git a/packages/server/src/automations/tests/loop.spec.ts b/packages/server/src/automations/tests/loop.spec.ts index 2c6ae9749d..ba237d3253 100644 --- a/packages/server/src/automations/tests/loop.spec.ts +++ b/packages/server/src/automations/tests/loop.spec.ts @@ -4,6 +4,7 @@ import { loopAutomation } from "../../tests/utilities/structures" import { context } from "@budibase/backend-core" import * as setup from "./utilities" import { Table } from "@budibase/types" +import * as loopUtils from "../loopUtils" import { LoopInput, LoopStepType } from "../../definitions/automations" describe("Attempt to run a basic loop automation", () => { @@ -51,4 +52,98 @@ describe("Attempt to run a basic loop automation", () => { }) expect(resp.steps[2].outputs.iterations).toBe(1) }) + + describe("replaceFakeBindings", () => { + it("should replace loop bindings in nested objects", () => { + const originalStepInput = { + schema: { + name: { + type: "string", + constraints: { + type: "string", + length: { maximum: null }, + presence: false, + }, + name: "name", + display: { type: "Text" }, + }, + }, + row: { + tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad", + name: "{{ loop.currentItem.pokemon }}", + }, + } + + const loopStepNumber = 3 + + const result = loopUtils.replaceFakeBindings( + originalStepInput, + loopStepNumber + ) + + expect(result).toEqual({ + schema: { + name: { + type: "string", + constraints: { + type: "string", + length: { maximum: null }, + presence: false, + }, + name: "name", + display: { type: "Text" }, + }, + }, + row: { + tableId: "ta_aaad4296e9f74b12b1b90ef7a84afcad", + name: "{{ steps.3.currentItem.pokemon }}", + }, + }) + }) + + it("should handle null values in nested objects", () => { + const originalStepInput = { + nullValue: null, + nestedNull: { + someKey: null, + }, + validValue: "{{ loop.someValue }}", + } + + const loopStepNumber = 2 + + const result = loopUtils.replaceFakeBindings( + originalStepInput, + loopStepNumber + ) + + expect(result).toEqual({ + nullValue: null, + nestedNull: { + someKey: null, + }, + validValue: "{{ steps.2.someValue }}", + }) + }) + + it("should handle empty objects and arrays", () => { + const originalStepInput = { + emptyObject: {}, + emptyArray: [], + nestedEmpty: { + emptyObj: {}, + emptyArr: [], + }, + } + + const loopStepNumber = 1 + + const result = loopUtils.replaceFakeBindings( + originalStepInput, + loopStepNumber + ) + + expect(result).toEqual(originalStepInput) + }) + }) }) From d9e36e92d26c54820f6b8440b0e4bcf85ae07e1b Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 3 Jul 2024 09:10:24 +0000 Subject: [PATCH 4/4] Bump version to 2.29.8 --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 6b36ce4849..71ba1a5401 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "2.29.7", + "version": "2.29.8", "npmClient": "yarn", "packages": [ "packages/*",