hcengineering/platform · error
Missing config for attributes: ${missingEnv.join(', ')}
Error message
Missing config for attributes: ${missingEnv.join(', ')} What it means
The media service (pods/media) builds its Config from environment variables at module initialization and throws if any required variable is undefined. This fail-fast validation prevents the service from running with partial configuration (e.g. missing storage or queue settings).
Source
Thrown at pods/media/src/config.ts:37
export interface Config {
AccountsUrl: string
Secret: string
ServiceID: string
Partitions: number
}
const config: Config = (() => {
const params: Partial<Config> = {
AccountsUrl: process.env.ACCOUNTS_URL,
Secret: process.env.SECRET,
ServiceID: process.env.SERVICE_ID ?? 'media',
Partitions: parseNumber(process.env.PARTITIONS) ?? 1
}
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
})()
function parseNumber (str: string | undefined): number | undefined {
if (str !== undefined) {
const intValue = Number.parseInt(str)
if (Number.isInteger(intValue)) {
return intValue
}
}
}
export default config
View on GitHub (pinned to 63e28dc964)
Solutions
- Set every variable listed in the error message before starting the service
- Diff your environment against the current Config in pods/media/src/config.ts and add newly introduced variables
- Fix env name typos (case-sensitive) in manifests and .env files
- For truly optional values, give them defaults in config.ts like Partitions' parseNumber fallback
Example fix
// before Storage: process.env.STORAGE_URL // undefined if unset -> throws // after Storage: process.env.STORAGE_URL ?? 'http://localhost:9000'
Defensive patterns
Strategy: validation
Validate before calling
const required = ['MONGO_URL', 'STORAGE_URL', 'PARTITIONS'] // keys from pods/media Config
const missing = required.filter((k) => process.env[k] === undefined)
if (missing.length > 0) {
throw new Error(`media service missing env vars: ${missing.join(', ')}`)
} Type guard
function isEnvComplete(keys: readonly string[], env: NodeJS.ProcessEnv): boolean {
return keys.every((k) => typeof env[k] === 'string' && env[k] !== '')
} Try / catch
let config: Config
try {
config = (await import('./config')).default
} catch (err) {
if (err instanceof Error && err.message.startsWith('Missing config for attributes')) {
console.error('Fix media env config:', err.message)
process.exit(1)
}
throw err
} Prevention
- Fill every variable from the media .env-template; never ship partial env files
- Re-check config.ts after each platform upgrade for new required keys
- Prefer explicit defaults (like parseNumber fallback) for optional values
- Run a pre-start env validation script in container entrypoints
When it happens
Trigger: Launching pods/media with missing required env vars (per its Config: e.g. storage endpoints, MONGO_URL, PARTITIONS-related vars, credentials); an env var intentionally optional but not defaulted in code; typos in variable names.
Common situations: Fresh deployments where the .env template was not fully filled in; Helm/compose files not updated after new config keys were added in an upgrade; running the service locally without sourcing the env file.
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
- Missing config for attributes: ${missingEnv.join(', ')}
- Missing config for attributes: ${missingEnv.join(', ')}
- Missing env variables: ${missingEnv.join(', ')}
- Missing env variables: ${missingEnv.join(', ')}
- One of endpoint/accessKey/secretKey values are not specified
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/dcab948b2363c2b9.
Report an issue: GitHub.