{"record":{"id":"822d395ae46c4c94","repo":"hcengineering/platform","slug":"queue-config-env-var-is-not-set","errorCode":null,"errorMessage":"QUEUE_CONFIG env var is not set","messagePattern":"QUEUE_CONFIG env var is not set","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"services/mail/pod-mail-worker/src/config.ts","lineNumber":63,"sourceCode":"      return process.env.WORKSPACE_URL\n    }\n    throw Error('WORKSPACE_URL env var is not set')\n  })(),\n  ignoredAddresses: process.env.IGNORED_ADDRESSES?.split(',') ?? [],\n  hookToken: process.env.HOOK_TOKEN,\n  mailSizeLimit: process.env.MAIL_SIZE_LIMIT ?? '50mb',\n  storageConfig: process.env.STORAGE_CONFIG,\n  kvsUrl: (() => {\n    if (process.env.KVS_URL !== undefined) {\n      return process.env.KVS_URL\n    }\n    throw Error('KVS_URL env var is not set')\n  })(),\n  queueConfig: (() => {\n    if (process.env.QUEUE_CONFIG !== undefined) {\n      return process.env.QUEUE_CONFIG\n    }\n    throw Error('QUEUE_CONFIG env var is not set')\n  })(),\n  queueRegion: process.env.QUEUE_REGION ?? '',\n  communicationTopic: process.env.COMMUNICATION_TOPIC ?? 'hulygun',\n  serviceId: process.env.SERVICE_ID ?? 'huly-mail',\n  mailUrl: (() => {\n    if (process.env.MAIL_URL !== undefined) {\n      return process.env.MAIL_URL\n    }\n    throw Error('MAIL_URL env var is not set')\n  })(),\n  mailAuth: process.env.MAIL_AUTH ?? '',\n  footerMessage: process.env.FOOTER_MESSAGE ?? '<br><br><p>Sent via <a href=\"https://huly.io\">Huly</a></p>',\n  outgoingSyncStartDate: new Date(process.env.OUTGOING_SYNC_START_DATE ?? '2025-08-20T00:00:00.000Z')\n}\n\nexport default config\n","sourceCodeStart":45,"sourceCodeEnd":80,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/mail/pod-mail-worker/src/config.ts#L45-L80","documentation":"In services/mail/pod-mail-worker/src/config.ts, queueConfig is resolved by an inline IIFE that returns process.env.QUEUE_CONFIG when defined and otherwise throws this error. The worker needs queue settings to send/receive mail events, so a missing QUEUE_CONFIG stops the process at import time.","triggerScenarios":"process.env.QUEUE_CONFIG is undefined when config.ts is first imported. Empty string would pass this specific check (only `!== undefined` is tested).","commonSituations":"Queue config secret not mounted; queue infra (e.g. SQS/RabbitMQ settings JSON) not provisioned for the mail worker; local run without the queue section in .env.","solutions":["Set QUEUE_CONFIG (usually a JSON string with queue URL/region/credentials) in the worker's environment.","Validate the JSON parses before deploying; downstream consumers typically JSON.parse this value.","Mirror the production QUEUE_CONFIG in your local .env for development.","Check the message queue itself is provisioned and reachable with the given config."],"exampleFix":"// before\nQUEUE_CONFIG unset -> throw at import\n// after\n# .env\nQUEUE_CONFIG={\"queueUrl\":\"https://sqs.us-east-1.amazonaws.com/123/mail\",\"region\":\"us-east-1\"}","handlingStrategy":"validation","validationCode":"const required = ['QUEUE_CONFIG', 'WORKSPACE_URL', 'KVS_URL', 'MAIL_URL'];\nconst missing = required.filter((k) => process.env[k] === undefined);\nif (missing.length) {\n  console.error('Missing mail-worker env vars:', missing.join(', '));\n  process.exit(1);\n}\nJSON.parse(process.env.QUEUE_CONFIG!); // must be valid JSON","typeGuard":"function isDefined<T>(v: T | undefined): v is T {\n  return v !== undefined;\n}","tryCatchPattern":"try {\n  const { default: config } = await import('./src/config.js');\n} catch (e) {\n  if ((e as Error).message === 'QUEUE_CONFIG env var is not set') {\n    console.error('Configure QUEUE_CONFIG with the queue connection settings JSON');\n  }\n  process.exit(1);\n}","preventionTips":["Store QUEUE_CONFIG as a structured secret and validate its JSON schema in CI.","Provision the queue alongside the worker in infrastructure-as-code.","Add a startup check that connects to the queue using the parsed config."],"tags":["environment","configuration","queue","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}