{"record":{"id":"c606a9da8840bb3b","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/backup-service/src/config.ts","lineNumber":92,"sourceCode":"    Secret: process.env[envMap.Secret],\n    BucketName: process.env[envMap.BucketName] ?? 'backups',\n    ServiceID: process.env[envMap.ServiceID] ?? 'backup-service',\n    Interval: parseInt(process.env[envMap.Interval] ?? '3600'),\n    Timeout: parseInt(process.env[envMap.Timeout] ?? '3600'),\n    CoolDown: parseInt(process.env[envMap.CoolDown] ?? '300'),\n    DbURL: process.env[envMap.DbURL],\n    SkipWorkspaces: process.env[envMap.SkipWorkspaces] ?? '',\n    WorkspaceStorage: process.env[envMap.WorkspaceStorage],\n    Storage: process.env[envMap.Storage],\n    Region: process.env[envMap.Region] ?? '',\n    Parallel: parseInt(process.env[envMap.Parallel] ?? '1'),\n    KeepSnapshots: parseInt(process.env[envMap.KeepSnapshots] ?? '84')\n  }\n\n  const missingEnv = required.filter((key) => params[key] === undefined).map((key) => envMap[key])\n\n  if (missingEnv.length > 0) {\n    throw Error(`Missing env variables: ${missingEnv.join(', ')}`)\n  }\n\n  return params as Config\n}\n","sourceCodeStart":74,"sourceCodeEnd":97,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/server/backup-service/src/config.ts#L74-L97","documentation":"The backup-service config loader validates required service configuration at startup. It builds a Config object from environment variables and throws this error if any entry in the `required` list is undefined. This fail-fast behavior prevents the service from starting with incomplete configuration (e.g. no DB URL or storage config).","triggerScenarios":"Starting the backup-service without any of the required env vars: ACCOUNTS_URL, ACCOUNTS_DB_URL, SECRET, SERVICE_ID, BUCKET_NAME, DB_URL, STORAGE, WORKSPACE_STORAGE (all listed in `required`, even those with defaults). Thrown from config() at server/backup-service/src/config.ts:92.","commonSituations":"Deploying via k8s/docker with a partial ConfigMap; forgetting STORAGE or DB_URL; renaming env vars after a service upgrade; running the service locally without a .env file.","solutions":["Set the env vars named in the error message (it lists the exact missing names like ACCOUNTS_URL, DB_URL).","Check your deployment manifest (k8s env, docker -e, .env file) includes all required vars for backup-service.","If a var like BUCKET_NAME should be optional, add a `??` default and remove it from the `required` array in src/config.ts.","Verify secrets (SECRET) are mounted correctly in your secret manager."],"exampleFix":"// before\nACCOUNTS_URL=https://accounts DB_URL=  # DB_URL empty\n// after\nACCOUNTS_URL=https://accounts.example.com\nDB_URL=postgresql://user:pass@db:5432/huly\nSECRET=...\nSTORAGE={\"kind\":\"s3\",...}","handlingStrategy":"validation","validationCode":"const required = ['ACCOUNTS_URL','ACCOUNTS_DB_URL','SECRET','SERVICE_ID','BUCKET_NAME','DB_URL','STORAGE','WORKSPACE_STORAGE']\nconst missing = required.filter((k) => process.env[k] === undefined)\nif (missing.length > 0) throw new Error(`Missing env variables: ${missing.join(', ')}`)","typeGuard":"function hasEnv(key: string): boolean {\n  return process.env[key] !== undefined\n}","tryCatchPattern":"try {\n  await startBackupService()\n} catch (err) {\n  if ((err as Error).message.startsWith('Missing env variables:')) {\n    console.error('Configuration error:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["Keep an .env.example listing all required vars and validate on container start.","Fail fast in CI by running a config preflight step before deploy.","Use a schema validator (zod/ajv) over process.env before launching services.","Pin env var names in your k8s manifests and diff them against .env.example in code review."],"tags":["configuration","environment-variables","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}