hcengineering/platform · error · Error

Missing env variables: ${missingEnv.join(', ')}

Error message

Missing env variables: ${missingEnv.join(', ')}

What it means

The pod-telegram service config merges defaults with env values but first checks that every key in `required` is defined, throwing and listing the missing env variable names. It is a startup fail-fast before mergeConfigs is applied.

Source

Thrown at services/telegram/pod-telegram/src/config.ts:82

const config = (() => {
  const ttl = parseNumber(process.env[envMap.TelegramAuthTTL])
  const params: Partial<Config> = {
    Host: process.env[envMap.Host],
    Port: parseNumber(process.env[envMap.Port]),
    TelegramApiID: parseNumber(process.env[envMap.TelegramApiID]),
    TelegramApiHash: process.env[envMap.TelegramApiHash],
    TelegramAuthTTL: ttl === undefined ? ttl : ttl * 1000,
    MongoDB: process.env[envMap.MongoDB],
    MongoURI: process.env[envMap.MongoURI],
    AccountsURL: process.env[envMap.AccountsURL],
    ServiceID: process.env[envMap.ServiceID],
    Secret: process.env[envMap.Secret]
  }

  const missingEnv = required.filter((key) => params[key] === undefined).map((key) => envMap[key])

  if (missingEnv.length > 0) {
    throw Error(`Missing env variables: ${missingEnv.join(', ')}`)
  }

  const res = mergeConfigs<Config>(defaults, params)
  return res
})()

export default config

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Set the env variables named in the error message and restart.
  2. Compare your env against required/envMap in services/telegram/pod-telegram/src/config.ts.
  3. Provide Secret and other credentials via the platform's secret management instead of hardcoding.
  4. If a key should be optional, move it out of `required` or give it a ?? default.

Example fix

// before
# missing TELEGRAM_API_HASH
// after
TELEGRAM_API_ID=123456
TELEGRAM_API_HASH=abcdef1234567890
SECRET=secret
Defensive patterns

Strategy: validation

Validate before calling

const required = ['TELEGRAM_API_ID', 'TELEGRAM_API_HASH', 'SECRET'] // mirror envMap in config.ts
const missing = required.filter((k) => process.env[k] === undefined)
if (missing.length > 0) throw new Error(`pod-telegram missing env: ${missing.join(', ')}`)

Type guard

function allSet(envMap: Record<string, string>): boolean {
  return Object.values(envMap).every((name) => process.env[name] !== undefined)
}

Try / catch

try {
  await import('./config.js')
} catch (err) {
  if (err.message.startsWith('Missing env variables:')) {
    console.error('pod-telegram requires:', err.message)
    process.exit(1)
  }
  throw err
}

Prevention

When it happens

Trigger: Starting pod-telegram without required env variables such as telegram API credentials, endpoint, or secret — envMap.Secret here has no ?? fallback, unlike rekoni.

Common situations: Missing session/API keys in deployment, secrets not injected, .env ignored, or version upgrades adding required vars; the pod crashes on boot.

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


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/b3fbde18ffd0958a. Report an issue: GitHub.