{"record":{"id":"fc97f366a2873e49","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join-fc97f3","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/notification/pod-notification/src/config.ts","lineNumber":51,"sourceCode":"\nconst parseNumber = (str: string | undefined): number | undefined => (str !== undefined ? Number(str) : undefined)\n\nconst config: Config = (() => {\n  const params: Partial<Config> = {\n    Port: parseNumber(process.env[envMap.Port]) ?? 8091,\n    Source: process.env[envMap.Source],\n    AuthToken: process.env[envMap.AuthToken],\n    PushPublicKey: process.env[envMap.PushPublicKey],\n    PushPrivateKey: process.env[envMap.PushPrivateKey],\n    PushSubject: process.env[envMap.PushSubject]\n  }\n\n  const required: Array<keyof Config> = ['Port', 'Source']\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\nexport default config\n","sourceCodeStart":33,"sourceCodeEnd":58,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/notification/pod-notification/src/config.ts#L33-L58","documentation":"pod-notification's config IIFE validates that required Config fields Port and Source are defined, mapping them back to their env var names via envMap. If either is undefined, it throws an error listing the missing env variable names (typically PORT and SOURCE).","triggerScenarios":"Starting pod-notification with the Port or Source env var unset — e.g. PORT provided but SOURCE missing, or both absent.","commonSituations":"New deployment missing the notification service's SOURCE variable (often a service identity string); env keys renamed in envMap so older variable names no longer match; local run without the service's .env.","solutions":["Set all required env vars: PORT (numeric) and SOURCE (source service identifier) per envMap in pod-notification/src/config.ts.","Read the error message — it names the missing variables exactly.","Compare your env file against the service's envMap/README to catch renamed keys.","Confirm the .env/secret is loaded into the process (check container env with `printenv` or `docker exec ... env`)."],"exampleFix":"// before\nPORT=4004\n// after\nPORT=4004\nSOURCE=notification-service","handlingStrategy":"validation","validationCode":"const required = ['PORT', 'SOURCE'];\nconst missing = required.filter((k) => process.env[k] === undefined || process.env[k] === '');\nif (missing.length) {\n  throw new Error(`pod-notification missing env vars: ${missing.join(', ')}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await import('./config');\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Missing env variables:')) {\n    console.error(`pod-notification env incomplete: ${err.message}`);\n    process.exit(1);\n  }\n  throw err;\n}","preventionTips":["Always set both PORT and SOURCE for the notification service; the error text names what is missing.","Cross-check env keys against envMap in pod-notification/src/config.ts after any rename.","Verify with `printenv` inside the container that the vars reach the process.","Validate env in CI using a schema validator (envalid/zod)."],"tags":["env","configuration","startup","notification"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}