From fe7e1adc1f19119602b965bb5d6c0af9fd692029 Mon Sep 17 00:00:00 2001 From: Yulian Diaz <5605867+spatialy@users.noreply.github.com> Date: Wed, 25 Feb 2026 04:57:30 +0000 Subject: [PATCH 1/2] fix(account): handle empty array in $in SQL clause to prevent PostgreSQL syntax error buildWhereClause now emits FALSE for empty $in arrays instead of invalid IN () syntax. Also adds an early return in getWorkspacesInfoWithStatusByIds so callers like the GitHub/Gmail/Backup services never hit the query with an empty uuid list. Fixes #10553 Signed-off-by: Yulian Diaz <5605867+spatialy@users.noreply.github.com> --- server/account/src/collections/postgres/postgres.ts | 4 ++++ server/account/src/utils.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/server/account/src/collections/postgres/postgres.ts b/server/account/src/collections/postgres/postgres.ts index 4bb1b8e0193..53bc5f98ba8 100644 --- a/server/account/src/collections/postgres/postgres.ts +++ b/server/account/src/collections/postgres/postgres.ts @@ -176,6 +176,10 @@ implements DbCollection { switch (operator) { case '$in': { const inVals = Object.values(qKey as object)[0] + if (inVals.length === 0) { + whereChunks.push('FALSE') + break + } const inVars: string[] = [] for (const val of inVals) { currIdx++ diff --git a/server/account/src/utils.ts b/server/account/src/utils.ts index bb9497f5c92..bfdd8732ca2 100644 --- a/server/account/src/utils.ts +++ b/server/account/src/utils.ts @@ -1351,6 +1351,7 @@ export async function getWorkspacesInfoWithStatusByIds ( db: AccountDB, uuids: WorkspaceUuid[] ): Promise { + if (uuids.length === 0) return [] const statuses = await db.workspaceStatus.find({ workspaceUuid: { $in: uuids } }) const statusesMap = statuses.reduce>((sm, s) => { sm[s.workspaceUuid] = s From 8fc1bd20d9573507967a6fe0a43512f5f304cdf7 Mon Sep 17 00:00:00 2001 From: Yulian Diaz <5605867+spatialy@users.noreply.github.com> Date: Wed, 25 Feb 2026 14:40:52 +0000 Subject: [PATCH 2/2] fix(account): also guard against non-array uuids in getWorkspacesInfoWithStatusByIds Per review feedback from @ArtyomSavchenko: use Array.isArray() in addition to the length check to handle runtime cases where uuids may not be an array. Signed-off-by: Yulian Diaz <5605867+spatialy@users.noreply.github.com> --- server/account/src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/account/src/utils.ts b/server/account/src/utils.ts index bfdd8732ca2..ab6103bbbaf 100644 --- a/server/account/src/utils.ts +++ b/server/account/src/utils.ts @@ -1351,7 +1351,7 @@ export async function getWorkspacesInfoWithStatusByIds ( db: AccountDB, uuids: WorkspaceUuid[] ): Promise { - if (uuids.length === 0) return [] + if (!Array.isArray(uuids) || uuids.length === 0) return [] const statuses = await db.workspaceStatus.find({ workspaceUuid: { $in: uuids } }) const statusesMap = statuses.reduce>((sm, s) => { sm[s.workspaceUuid] = s