From d9640ccaa0ada02163d39476ba49e762fbca3c71 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Sun, 11 Aug 2024 18:31:56 +0700 Subject: [PATCH] UBERF-7865: Fix wrong access to not created collection (#6315) Signed-off-by: Andrey Sobolev --- dev/docker-compose.yaml | 2 ++ pods/account/src/__start.ts | 2 +- server/core/src/server/domainHelper.ts | 1 + server/mongo/src/utils.ts | 7 +++++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 0446d5e8ba..c7ad489a68 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -62,6 +62,8 @@ services: - LAST_NAME_FIRST=true - ACCOUNTS_URL=http://localhost:3000 - BRANDING_PATH=/var/cfg/branding.json + - INIT_SCRIPT_URL=https://raw.githubusercontent.com/hcengineering/init/main/script.yaml + - INIT_WORKSPACE=onboarding restart: unless-stopped collaborator: image: hardcoreeng/collaborator diff --git a/pods/account/src/__start.ts b/pods/account/src/__start.ts index 113f03a061..11e9ec066c 100644 --- a/pods/account/src/__start.ts +++ b/pods/account/src/__start.ts @@ -16,7 +16,7 @@ const disabled = (process.env.MODEL_DISABLED ?? '').split(',').map((it) => it.tr const txes = JSON.parse(JSON.stringify(builder(enabled, disabled).getTxes())) as Tx[] configureAnalytics(process.env.SENTRY_DSN, {}) -Analytics.setTag('application', 'transactor') +Analytics.setTag('application', 'account') const metricsContext = new MeasureMetricsContext( 'account', diff --git a/server/core/src/server/domainHelper.ts b/server/core/src/server/domainHelper.ts index 23f6fb3fa5..2f236cdfb6 100644 --- a/server/core/src/server/domainHelper.ts +++ b/server/core/src/server/domainHelper.ts @@ -174,6 +174,7 @@ export class DomainIndexHelperImpl implements DomainHelper { } } } catch (err: any) { + ctx.error('error during domain collections/indexes check', { domain, error: err }) Analytics.handleError(err) } diff --git a/server/mongo/src/utils.ts b/server/mongo/src/utils.ts index 9e32881cf0..646a5aecb7 100644 --- a/server/mongo/src/utils.ts +++ b/server/mongo/src/utils.ts @@ -230,7 +230,10 @@ export class DBCollectionHelper implements DomainHelperOperations { } async estimatedCount (domain: Domain): Promise { - const c = this.collection(domain) - return await c.estimatedDocumentCount() + if (this.exists(domain)) { + const c = this.collection(domain) + return await c.estimatedDocumentCount() + } + return 0 } }