hcengineering/platform · error · Error

Missing config for attributes: ${missingEnv.join(', ')}

Error message

Missing config for attributes: ${missingEnv.join(', ')}

What it means

The pod-telegram-bot service validates its Config at startup inside a module IIFE and throws if any parameter (including QueueConfig from QUEUE_CONFIG) is undefined. Unlike some sibling services it has no required filtering or defaults here, so every undefined key triggers the error.

Source

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

    AccountsUrl: process.env.ACCOUNTS_URL,
    ServiceId: process.env.SERVICE_ID ?? 'telegram-bot',
    Secret: process.env.SECRET,
    Domain: process.env.DOMAIN ?? '',
    BotPort: parseNumber(process.env.BOT_PORT) ?? 8443,
    // TODO: later we should get this title from branding map
    App: process.env.APP ?? 'Huly',
    OtpTimeToLiveSec: parseNumber(process.env.OTP_TIME_TO_LIVE_SEC) ?? 5 * 60,
    OtpRetryDelaySec: parseNumber(process.env.OTP_RETRY_DELAY_SEC) ?? 60,
    AccountsURL: process.env.ACCOUNTS_URL,
    DbUrl: process.env.DB_URL,
    QueueRegion: process.env.QUEUE_REGION,
    QueueConfig: process.env.QUEUE_CONFIG
  }

  const missingEnv = (Object.keys(params) as Array<keyof Config>).filter((key) => params[key] === undefined)

  if (missingEnv.length > 0) {
    throw Error(`Missing config for attributes: ${missingEnv.join(', ')}`)
  }

  return params as Config
})()

export default config

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Set the missing variables named in the error and restart the pod.
  2. Define QUEUE_CONFIG as a valid queue connection string/JSON.
  3. Check services/telegram-bot/pod-telegram-bot/src/config.ts for the full key list and expected env names.
  4. For optional keys, add ?? defaults in the params object.

Example fix

// before
# no QUEUE_CONFIG
// after
QUEUE_CONFIG={"host":"rabbitmq","port":5672}
TELEGRAM_TOKEN=123456:ABC-DEF
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

function hasEnv(keys: string[]): boolean { return keys.every((k) => process.env[k] !== undefined) }

Try / catch

try {
  await import('./config.js')
} catch (err) {
  if (err.message.startsWith('Missing config for attributes:')) {
    console.error('Set bot env vars and restart:', err.message)
    process.exit(1)
  }
  throw err
}

Prevention

When it happens

Trigger: Starting pod-telegram-bot without QUEUE_CONFIG or any other bot env variable (telegram token, endpoint, secret) set; env vars not propagated into the container.

Common situations: Kubernetes secrets not mounted, docker-compose env missing, .env file absent, typos in variable names, or upgrades introducing new required config keys.

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/306fcb51089dad54. Report an issue: GitHub.