hcengineering/platform · error · Error
Missing env variables: ${missingEnv.join(', ')}
Error message
Missing env variables: ${missingEnv.join(', ')} What it means
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.
Source
Thrown at services/ai-bot/love-agent/src/config.ts:70
SttProvider: (process.env.STT_PROVIDER as SttProvider) ?? 'deepgram',
VadSilenceDurationMs: parseInt(process.env.SILENCE_DURATION_MS ?? '1000'),
VadPrefixPaddingMs: parseInt(process.env.PREFIX_PADDING_MS ?? '1000'),
VadThreshold: parseFloat(process.env.VAD_THRESHOLD ?? '0.5'),
DgEndpointing: parseInt(process.env.DG_ENDPOINTING ?? '100'),
DgInterimResults: process.env.DG_INTERIM_RESULTS === 'true',
DgVadEvents: process.env.DG_VAD_EVENTS === 'true',
DgPunctuate: process.env.DG_PUNCTUATE === 'true',
DgSmartFormat: process.env.DG_SMART_FORMAT === 'true',
DgUtteranceEndMs: parseInt(process.env.DG_UTTERANCE_END_MS ?? '0'),
DgNoDelay: process.env.DG_NO_DELAY === 'true',
DgSampleRate: parseInt(process.env.DG_SAMPLE_RATE ?? '16000')
}
const missingEnv = (Object.keys(params) as Array<keyof Config>).filter((key) => params[key] === undefined)
if (missingEnv.length > 0) {
throw Error(`Missing env variables: ${missingEnv.join(', ')}`)
}
return params as Config
})()
export default config
View on GitHub (pinned to 63e28dc964)
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.
Example fix
// before npm start # PLATFORM_TOKEN unset -> throws // after export PLATFORM_TOKEN=eyJhbGci... export PLATFORM_URL=https://platform.example.com npm start
Defensive patterns
Strategy: validation
Validate before calling
const missing = ['PLATFORM_TOKEN', 'PLATFORM_URL'].filter((k) => process.env[k] === undefined)
if (missing.length > 0) throw new Error(`Missing env variables: ${missing.join(', ')}`) Type guard
function hasEnv(key: string): boolean {
return process.env[key] !== undefined
} Try / catch
// config throws at import time; wrap the dynamic import
try {
const { default: config } = await import('./config.js')
} catch (err) {
if ((err as Error).message.startsWith('Missing env variables:')) {
console.error('love-agent config error:', err.message)
process.exit(1)
}
throw err
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- Missing env variables: ${missingEnv.join(', ')}
- Missing config for attributes: ${missingEnv.join(', ')}
- Missing config for attributes: ${missingEnv.join(', ')}
- Missing config for attributes: ${missingEnv.join(', ')}
- Missing env variables: ${missingEnv.join(', ')}
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/0146650e3d1b7baa.
Report an issue: GitHub.