hcengineering/platform · critical · Error

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

Error message

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

What it means

The github service config module (services/github/pod-github/src/config.ts) maps Config keys to env var names via an `envMap` and throws this error when any required parameter is undefined. Unlike the sibling services, it reports the raw env variable names (from envMap) rather than config keys, e.g. the value of envMap.RateLimit. It is a fail-fast import-time validation.

Source

Thrown at services/github/pod-github/src/config.ts:103

    ClientSecret: process.env[envMap.ClientSecret],
    // https://github.com/octokit/auth-app.js/issues/465
    PrivateKey: process.env[envMap.PrivateKey]?.replace(/\\n/g, '\n'),
    WebhookSecret: process.env[envMap.WebhookSecret] ?? 'secret',
    EnterpriseHostname: process.env[envMap.EnterpriseHostname],
    Port: parseInt(process.env[envMap.Port] ?? '3500'),
    BotName: process.env[envMap.BotName] ?? 'ao-huly-dev[bot]',

    CollaboratorURL: process.env[envMap.CollaboratorURL],

    BrandingPath: process.env[envMap.BrandingPath] ?? '',
    WorkspaceInactivityInterval: parseInt(process.env[envMap.WorkspaceInactivityInterval] ?? '3'), // In days
    RateLimit: parseInt(process.env[envMap.RateLimit] ?? '25')
  }

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

  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

  1. Set each env variable named in the error message (they are the envMap names) in the runtime environment.
  2. Cross-check envMap in config.ts to map each reported name back to its Config key and its intended value format.
  3. If a variable should be optional, move it out of `required` or give it a default in the params object.
  4. Validate the full env locally by importing the config module in a script before deploying.

Example fix

// before
GITHUB_APP_ID unset -> "Missing env variables: GITHUB_APP_ID"
// after
# .env
GITHUB_APP_ID=123456
Defensive patterns

Strategy: validation

Validate before calling

// Mirror the envMap required list from services/github/pod-github/... config.ts
const required: string[] = [/* envMap values */];
const missing = required.filter((k) => process.env[k] === undefined);
if (missing.length) throw new Error(`Missing env variables: ${missing.join(', ')}`);

Type guard

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

Try / catch

try {
  const { default: config } = await import('./src/config.js');
} catch (e) {
  if ((e as Error).message.startsWith('Missing env variables')) {
    console.error('Set these GitHub service env vars:', (e as Error).message);
  }
  process.exit(1);
}

Prevention

When it happens

Trigger: One or more env vars listed in `required` are undefined when config.ts is imported; params[key] === undefined for such keys, e.g. envMap.RateLimit's backing variable missing (RateLimit itself defaults via parseInt ?? '25', so it would only fail if its env var is in the required set and unset for other keys).

Common situations: GitHub integration pod deployed without its required GitHub App credentials/env; env var renamed in envMap but not updated in deployment; running locally without a complete .env.

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