hcengineering/platform · critical · Error

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

Error message

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

What it means

The datalake service config module (services/datalake/pod-datalake/src/config.ts) builds a Config object at import time inside an IIFE and validates that every entry in `params` is defined. If any required config attribute is undefined — typically because its environment variable was not set — it throws this error listing all missing attribute names joined by ', '. It is a fail-fast guard so the service never starts with a partially configured Config.

Source

Thrown at services/datalake/pod-datalake/src/config.ts:111

    AccountsUrl: process.env.ACCOUNTS_URL,
    DbUrl: process.env.DB_URL,
    Buckets: parseBucketsConfig(process.env.BUCKETS),
    Secure: process.env.SECURE === 'true',
    Readonly: process.env.READONLY === 'true',
    Cache: {
      enabled: process.env.CACHE_ENABLED !== 'false',
      blobSize: (parseNumber(process.env.CACHE_BLOB_SIZE) ?? 64) * 1024, // Default 64KB
      blobCount: parseNumber(process.env.CACHE_BLOB_COUNT) ?? 1000
    },
    // Configured in megabytes via MAX_FILE_SIZE_MB (default 5120 MB = 5 GiB,
    // e.g. set to 10240 for 10 GiB).
    MaxFileSize: (parseNumber(process.env.MAX_FILE_SIZE_MB) ?? 5120) * 1024 * 1024
  }

  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. Read the attribute names listed in the error message; each corresponds to a key in params in config.ts with an associated process.env.* source.
  2. Set the listed environment variables in your deployment environment (K8s manifest, docker-compose, .env, CI secrets) before starting the service.
  3. For optional numeric tuning like MAX_FILE_SIZE_MB, note parseNumber(process.env.MAX_FILE_SIZE_MB) ?? 5120 already has a default — so if it is listed, the parse produced undefined rather than absent input; check the parse helper/value.
  4. Verify locally with the same env file used in production (e.g. `node -r dotenv/config src/index.ts`) that config.ts imports without throwing.

Example fix

// before (env missing)
MAX_FILE_SIZE_MB=  # unset or invalid
// after
# .env
MAX_FILE_SIZE_MB=5120
Defensive patterns

Strategy: validation

Validate before calling

// Run before importing the app (e.g. in entrypoint script)
const required = ['MAX_FILE_SIZE_MB' /* plus all env vars read in config.ts */];
const missing = required.filter((k) => process.env[k] === undefined);
if (missing.length) {
  console.error('Missing env vars:', missing.join(', '));
  process.exit(1);
}

Type guard

function hasEnv<K extends string>(key: K): key is K & keyof NodeJS.ProcessEnv {
  return process.env[key] !== undefined;
}

Try / catch

try {
  const { default: config } = await import('./src/config.js');
} catch (e) {
  console.error(`Config load failed: ${(e as Error).message}`);
  process.exit(1);
}

Prevention

When it happens

Trigger: Any process.env.* used to populate params (e.g. MAX_FILE_SIZE_MB, and all other Config keys) is undefined when the module is imported. Because config is loaded at import time, merely importing any module that re-exports config triggers the check.

Common situations: Deploying the datalake pod without a required env var in the deployment manifest / .env file; running locally without a filled .env; renaming an env var in code but not in the orchestrator config; typos in variable names in docker-compose, Kubernetes ConfigMap, or CI secrets.

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