hcengineering/platform · critical · Error
Missing env variables: ${missingEnv.join(', ')}
Error message
Missing env variables: ${missingEnv.join(', ')} What it means
The translate service config module reads required environment variables at load time and throws immediately if any are missing or empty, failing fast rather than running with an incomplete configuration.
Source
Thrown at services/translate/src/config.ts:50
const config: Config = (() => {
const params: Partial<Config> = {
Secret: process.env.SECRET ?? 'secret',
QueueConfig: process.env.QUEUE_CONFIG ?? '',
QueueRegion: process.env.QUEUE_REGION ?? '',
AccountsUrl: process.env.ACCOUNTS_URL ?? '',
HulylakeUrl: process.env.HULYLAKE_URL ?? '',
ServiceId: process.env.SERVICE_ID ?? 'translate',
OpenAIKey: process.env.OPENAI_API_KEY,
OpenAIModel: (process.env.OPENAI_MODEL ?? 'gpt-4o-mini') as OpenAI.ChatModel,
OpenAIBaseUrl: process.env.OPENAI_BASE_URL ?? '',
BillingUrl: process.env.BILLING_URL ?? ''
}
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 all required env variables (e.g. BILLING_URL) in the service environment and restart
- Add the missing variables to your .env file / deployment secret configuration
- Compare against the current config.ts to find variables added since your deployment was created
- Add a startup healthcheck that surfaces this message early in CI/deploy
Example fix
// before # start service with missing config yarn start translate // after export BILLING_URL=https://billing.example.com yarn start translate
Defensive patterns
Strategy: validation
Validate before calling
const required = ['BILLING_URL', 'ACCOUNTS_URL', 'MONGO_URL']
const missing = required.filter(k => !process.env[k])
if (missing.length > 0) throw new Error(`Missing env variables: ${missing.join(', ')}`) Try / catch
try {
await import('./config')
} catch (err) {
if (String(err.message).startsWith('Missing env variables:')) {
console.error('Startup failed:', err.message)
process.exit(1)
}
} Prevention
- Keep deployment secrets/env files in sync with config.ts
- Fail fast in CI by importing config during smoke tests
- Document every required variable and validate empty strings as missing
When it happens
Trigger: Starting the translate service without BILLING_URL (or any other required variable) set in the environment, or exporting it as an empty string.
Common situations: Deploying without the variable in the deployment config; .env file not loaded locally; variable renamed between versions so old deployments lack it.
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
- Please provide queue config
- Missing env variables: ${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/7c56cd9e2efdf8bb.
Report an issue: GitHub.