{"record":{"id":"3b9b3ecb280c6843","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join-3b9b3e","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/ai-bot/pod-ai-bot/src/config.ts","lineNumber":82,"sourceCode":"    OpenAITranslateModel: (process.env.OPENAI_TRANSLATE_MODEL ?? 'gpt-4o-mini') as OpenAI.ChatModel,\n    OpenAISummaryModel: (process.env.OPENAI_SUMMARY_MODEL ?? 'gpt-4o-mini') as OpenAI.ChatModel,\n    OpenAIBaseUrl: process.env.OPENAI_BASE_URL ?? '',\n    MaxContentTokens: parseNumber(process.env.MAX_CONTENT_TOKENS) ?? 128 * 100,\n    MaxHistoryRecords: parseNumber(process.env.MAX_HISTORY_RECORDS) ?? 500,\n    Port: parseNumber(process.env.PORT) ?? 4010,\n    LoveEndpoint: process.env.LOVE_ENDPOINT ?? '',\n    DataLabApiKey: process.env.DATALAB_API_KEY ?? '',\n    BillingUrl: process.env.BILLING_URL ?? '',\n    DeepgramPollIntervalMinutes: parseNumber(process.env.DEEPGRAM_POLL_INTERVAL_MINUTES) ?? 60,\n    DeepgramApiKey: process.env.DEEPGRAM_API_KEY ?? '',\n    DeepgramProjectId: process.env.DEEPGRAM_PROJECT_ID ?? '',\n    DeepgramTag: process.env.DEEPGRAM_TAG ?? ''\n  }\n\n  const missingEnv = (Object.keys(params) as Array<keyof Config>).filter((key) => params[key] === undefined)\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":64,"sourceCodeEnd":89,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/ai-bot/pod-ai-bot/src/config.ts#L64-L89","documentation":"The pod-ai-bot config IIFE validates that no Config field is undefined and throws at import time otherwise. Most fields have defaults; only ACCOUNTS_URL, MONGO_URL, SERVER_SECRET, FIRST_NAME and LAST_NAME lack fallbacks, so those are the values that can actually trigger the throw.","triggerScenarios":"Importing services/ai-bot/pod-ai-bot/src/config.ts without one of: ACCOUNTS_URL, MONGO_URL, SERVER_SECRET, FIRST_NAME, LAST_NAME. The error lists the Config keys, e.g. 'MongoURL, ServerSecret'.","commonSituations":"Deploying ai-bot without a MongoDB URL or server secret; forgetting the bot identity vars FIRST_NAME/LAST_NAME; local run without .env; ConfigMap trimmed during a redeploy.","solutions":["Set the env vars named in the message — typically MONGO_URL, SERVER_SECRET, ACCOUNTS_URL, FIRST_NAME, LAST_NAME.","Check k8s ConfigMap/Secret references actually exist and keys match exactly.","Create a local .env covering these five vars before running the bot.","If a var should be optional, add a `??` default in src/config.ts and it will stop being reported."],"exampleFix":"// before\nFIRST_NAME=Huly  # MONGO_URL missing\n// after\nACCOUNTS_URL=https://accounts.example.com\nMONGO_URL=mongodb://mongo:27017\nSERVER_SECRET=...\nFIRST_NAME=Huly\nLAST_NAME=AI","handlingStrategy":"validation","validationCode":"const required = ['ACCOUNTS_URL','MONGO_URL','SERVER_SECRET','FIRST_NAME','LAST_NAME']\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  const { default: config } = await import('./config.js')\n} catch (err) {\n  if ((err as Error).message.startsWith('Missing env variables:')) {\n    console.error('ai-bot config error:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["List the five required vars (ACCOUNTS_URL, MONGO_URL, SERVER_SECRET, FIRST_NAME, LAST_NAME) in .env.example.","Verify ConfigMap/Secret key spelling during deployment review.","Add a startup preflight that checks required env before importing the service.","Use the same SERVER_SECRET value across services that must interoperate."],"tags":["configuration","environment-variables","ai-bot"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}