{"record":{"id":"dac31dd47049cbad","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join-dac31d","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/rekoni/src/config.ts","lineNumber":44,"sourceCode":"  ServiceID: 'SERVICE_ID',\n  Secret: 'SECRET'\n}\n\nconst required: Array<keyof Config> = ['ServiceID', 'Secret']\n\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] ?? '4004'),\n    ServiceID: process.env[envMap.ServiceID] ?? 'rekoni-service',\n    Secret: process.env[envMap.Secret] ?? 'secret'\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\nexport default config\n","sourceCodeStart":26,"sourceCodeEnd":51,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/rekoni/src/config.ts#L26-L51","documentation":"The rekoni service config module validates required environment variables at startup (module-level IIFE) and throws synchronously if any required value resolves to undefined. The message lists the missing env variable names from envMap, making it a startup-time fail-fast guard.","triggerScenarios":"Starting services/rekoni without setting one of the required env variables listed in envMap/required. Only required keys without a ?? default trigger this; Secret has a 'secret' fallback here, so other required keys are the usual culprits.","commonSituations":"Docker/Kubernetes deployments with missing env entries, a .env file not loaded, typos in env variable names, or a newly added required config key after upgrading the service.","solutions":["Read the missing variable names from the error and set them in the deployment environment (.env, docker-compose, k8s manifest).","Check services/rekoni/src/config.ts for the required keys and envMap to get exact variable names.","If a variable is optional in your setup, add a default with ?? in the params object.","Restart the service after setting the variables — config is computed once at import time."],"exampleFix":"// before (deploy env)\nREKONI_ENDPOINT=https://rekoni\n# SECRET_TOKEN missing\n// after (deploy env)\nREKONI_ENDPOINT=https://rekoni\nSECRET_TOKEN=xxxx","handlingStrategy":"validation","validationCode":"// run before importing the service\nconst required = ['REKONI_ENDPOINT', 'SECRET_TOKEN'] // mirror config.ts required/envMap\nconst missing = required.filter((k) => process.env[k] === undefined)\nif (missing.length > 0) throw new Error(`Missing env: ${missing.join(', ')}`)","typeGuard":"function hasEnv(keys: string[]): boolean { return keys.every((k) => process.env[k] !== undefined) }","tryCatchPattern":"try {\n  await import('./config.js') // config throws at module load\n} catch (err) {\n  if (err.message.startsWith('Missing env variables:')) {\n    console.error('Set the listed env vars and restart:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["Mirror required keys in a .env.example and a CI env-check.","Use secret management to inject env vars into deployments.","Add a startup readiness probe that fails loudly on config errors.","When upgrading, diff the config.ts required list against your deployment env."],"tags":["config","environment","startup","rekoni"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}