The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix incorrect fetch of userVars when userId is not specified
Charles Bochetdcb8c7c03a47
diff --git a/packages/twenty-server/src/engine/core-modules/user/user-vars/services/user-vars.service.ts b/packages/twenty-server/src/engine/core-modules/user/user-vars/services/user-vars.service.tsindex ba6f74f1c31..6ac037c7b3c 100644--- a/packages/twenty-server/src/engine/core-modules/user/user-vars/services/user-vars.service.ts+++ b/packages/twenty-server/src/engine/core-modules/user/user-vars/services/user-vars.service.ts@@ -32,11 +32,15 @@ export class UserVarsService<);}- const userVarUserLevel = await this.keyValuePairService.get({- type: KeyValuePairType.USER_VAR,- userId,- key,- });+ let userVarUserLevel: any[] = [];++ if (userId) {+ userVarUserLevel = await this.keyValuePairService.get({+ type: KeyValuePairType.USER_VAR,+ userId,+ key,+ });+ }if (userVarUserLevel.length > 1) {throw new Error(`Multiple values found for key ${key} at user level`);@@ -60,10 +64,14 @@ export class UserVarsService<workspaceId,});- const userVarsUserLevel = await this.keyValuePairService.get({- type: KeyValuePairType.USER_VAR,- userId,- });+ let userVarsUserLevel: any[] = [];++ if (userId) {+ userVarsUserLevel = await this.keyValuePairService.get({+ type: KeyValuePairType.USER_VAR,+ userId,+ });+ }return mergeUserVars<Extract<keyof KeyValueTypesMap, string>>([...userVarsWorkspaceLevel,