{"record":{"id":"0146650e3d1b7baa","repo":"hcengineering/platform","slug":"missing-env-variables-missingenv-join-014665","errorCode":null,"errorMessage":"Missing env variables: ${missingEnv.join(', ')}","messagePattern":"Missing env variables: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/ai-bot/love-agent/src/config.ts","lineNumber":70,"sourceCode":"    SttProvider: (process.env.STT_PROVIDER as SttProvider) ?? 'deepgram',\n    VadSilenceDurationMs: parseInt(process.env.SILENCE_DURATION_MS ?? '1000'),\n    VadPrefixPaddingMs: parseInt(process.env.PREFIX_PADDING_MS ?? '1000'),\n    VadThreshold: parseFloat(process.env.VAD_THRESHOLD ?? '0.5'),\n\n    DgEndpointing: parseInt(process.env.DG_ENDPOINTING ?? '100'),\n    DgInterimResults: process.env.DG_INTERIM_RESULTS === 'true',\n    DgVadEvents: process.env.DG_VAD_EVENTS === 'true',\n    DgPunctuate: process.env.DG_PUNCTUATE === 'true',\n    DgSmartFormat: process.env.DG_SMART_FORMAT === 'true',\n    DgUtteranceEndMs: parseInt(process.env.DG_UTTERANCE_END_MS ?? '0'),\n    DgNoDelay: process.env.DG_NO_DELAY === 'true',\n    DgSampleRate: parseInt(process.env.DG_SAMPLE_RATE ?? '16000')\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":52,"sourceCodeEnd":77,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/ai-bot/love-agent/src/config.ts#L52-L77","documentation":"The love-agent config IIFE builds its Config object from env vars and throws if any param is undefined. Unlike most fields, only PLATFORM_TOKEN and PLATFORM_URL lack `??` fallbacks, so they are the only values that can actually trigger this error at runtime.","triggerScenarios":"Importing services/ai-bot/love-agent/src/config.ts without PLATFORM_TOKEN or PLATFORM_URL set in the environment (every other field defaults to '' or a constant). The message names the config key(s): 'PlatformToken' and/or 'PlatformUrl'.","commonSituations":"Running the love-agent service locally without platform credentials; k8s deployment missing the platform token secret; copying an env template that doesn't include PLATFORM_* vars.","solutions":["Set PLATFORM_TOKEN and PLATFORM_URL in the service environment.","Ensure the platform token secret is mounted and the env key matches exactly (uppercase, underscores).","For local runs, create a .env with PLATFORM_TOKEN/PLATFORM_URL and load it (dotenv or --env-file).","If they should be optional, add defaults (e.g. `?? ''`) in src/config.ts."],"exampleFix":"// before\nnpm start  # PLATFORM_TOKEN unset -> throws\n// after\nexport PLATFORM_TOKEN=eyJhbGci...\nexport PLATFORM_URL=https://platform.example.com\nnpm start","handlingStrategy":"validation","validationCode":"const missing = ['PLATFORM_TOKEN', 'PLATFORM_URL'].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":"// config throws at import time; wrap the dynamic import\ntry {\n  const { default: config } = await import('./config.js')\n} catch (err) {\n  if ((err as Error).message.startsWith('Missing env variables:')) {\n    console.error('love-agent config error:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["Add PLATFORM_TOKEN and PLATFORM_URL to .env.example and your deploy template.","Mount the platform token via a secret manager, not plaintext env.","Validate env presence in the container entrypoint before node starts.","Keep local and CI envs in sync with the production variable list."],"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"}