{"record":{"id":"e75961d2ff9c9230","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join-e75961","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"services/gmail/pod-gmail/src/config.ts","lineNumber":92,"sourceCode":"    WATCH_TOPIC_NAME: process.env[envMap.WATCH_TOPIC_NAME],\n    InitLimit: parseNumber(process.env[envMap.InitLimit]) ?? 50,\n    FooterMessage: process.env[envMap.FooterMessage] ?? '<br><br><p>Sent via <a href=\"https://huly.io\">Huly</a></p>',\n    OutgoingSyncStartDate: new Date(process.env[envMap.OutgoingSyncStartDate] ?? '2025-08-20T00:00:00.000Z'),\n    KvsUrl: process.env[envMap.KvsUrl],\n    StorageConfig: process.env[envMap.StorageConfig],\n    Version: version,\n    QueueConfig: process.env[envMap.QueueConfig] ?? '',\n    QueueRegion: process.env[envMap.QueueRegion] ?? '',\n    CommunicationTopic: process.env[envMap.CommunicationTopic] ?? 'hulygun',\n    WorkspaceInactivityInterval: parseNumber(process.env[envMap.WorkspaceInactivityInterval] ?? '3') // In days\n  }\n\n  const missingEnv = (Object.keys(params) as Array<keyof Config>)\n    .filter((key) => params[key] === undefined)\n    .map((key) => envMap[key])\n\n  if (missingEnv.length > 0) {\n    throw Error(`Missing env variables: ${missingEnv.join(', ')}`)\n  }\n  if (version === IntegrationVersion.V2) {\n    if (params.QueueConfig === '') {\n      throw Error('Missing env variable: QUEUE_CONFIG')\n    }\n    if (params.CommunicationTopic === '') {\n      throw Error('Missing env variable: COMMUNICATION_TOPIC')\n    }\n  }\n\n  return params as Config\n})()\n\nexport default config\n","sourceCodeStart":74,"sourceCodeEnd":107,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/gmail/pod-gmail/src/config.ts#L74-L107","documentation":"The gmail service config module (services/gmail/pod-gmail/src/config.ts) validates params at import time, mapping missing keys to their env var names via envMap, and throws this error listing the unset variables. V2 integrations get additional checks afterwards (QUEUE_CONFIG, COMMUNICATION_TOPIC non-empty). This fail-fast guard prevents starting a Gmail integration with incomplete config.","triggerScenarios":"Any required env var backing a params key is undefined at import (the message shows envMap names). Note: params values that are empty strings '' do NOT trigger this error — they fall through to the V2-specific checks (errors 1234/1235).","commonSituations":"Gmail pod deployed without required Google OAuth/queue env vars; upgrading an integration to V2 where QUEUE_CONFIG becomes mandatory; missing .env in local development.","solutions":["Set every env variable named in the error message before starting the service.","If the error names QUEUE_CONFIG or COMMUNICATION_TOPIC as undefined, set them — for V2 they are additionally checked for empty strings.","Review envMap in config.ts to map each name to its Config key and expected format (e.g. JSON queue config).","Run a local import of config.ts with your .env to verify all variables resolve."],"exampleFix":"// before\nGMAIL_CLIENT_ID unset -> throw at import\n// after\n# .env\nGMAIL_CLIENT_ID=xxxx.apps.googleusercontent.com","handlingStrategy":"validation","validationCode":"const required: string[] = [/* envMap values for gmail config */];\nconst missing = required.filter((k) => process.env[k] === undefined);\nif (missing.length) throw new Error(`Missing env variables: ${missing.join(', ')}`);","typeGuard":"function isNonEmpty(v: string | undefined): v is string {\n  return v !== undefined && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const { default: config } = await import('./src/config.js');\n} catch (e) {\n  console.error(`Gmail config error: ${(e as Error).message}`);\n  process.exit(1);\n}","preventionTips":["On V2 migration, enumerate the new mandatory vars (QUEUE_CONFIG, COMMUNICATION_TOPIC) in the runbook.","Validate the full env with a startup smoke test before rollout.","Keep .env.example updated for both V1 and V2 variable sets."],"tags":["environment","configuration","startup","gmail"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}