hcengineering/platform · error
Missing config for attributes: ${missingEnv.join(', ')}
Error message
Missing config for attributes: ${missingEnv.join(', ')} What it means
The link-preview service validates its configuration at module load time: it builds a params object from environment variables and throws if any value is undefined. This fail-fast check ensures the service never starts with incomplete configuration.
Source
Thrown at pods/link-preview/src/config.ts:44
TimeoutMs?: number
MaxImageBytes?: number
}
const config: Config = (() => {
const params: Partial<Config> = {
Port: parseInt(process.env.PORT ?? '4041'),
Secret: process.env.SECRET,
ServiceID: process.env.SERVICE_ID ?? 'link-preview',
UserAgent: process.env.USER_AGENT ?? 'Huly Link Preview Service/1.0',
DescriptionMaxSentences: parseInt(process.env.DESCRIPTION_MAX_SENTENCES ?? '3'),
DescriptionMaxLength: parseInt(process.env.DESCRIPTION_MAX_LENGTH ?? '200'),
TimeoutMs: parseInt(process.env.TIMEOUT ?? '5') * 1000
}
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
- Read the missing attribute names from the error message and set those exact environment variables before starting the service
- Check your .env / deployment manifest (docker-compose, k8s env) includes every required key and matches spelling
- Verify the env file is actually loaded (mounted volume, --env-file flag, dotenv import)
- Use the shipped .env-template / config docs in pods/link-preview as the source of required variables
Example fix
# before transactor: image: link-preview # no env # after env: - MONGO_URL=mongodb://mongo:27017 - REDIS_URL=redis://redis:6379 - TIMEOUT=5
Defensive patterns
Strategy: validation
Validate before calling
const required = ['MONGO_URL', 'REDIS_URL', 'TIMEOUT'] // keys from pods/link-preview Config
const missing = required.filter((k) => process.env[k] === undefined)
if (missing.length > 0) {
throw new Error(`Set env vars before starting link-preview: ${missing.join(', ')}`)
} Type guard
function hasEnv<K extends string>(keys: K[], env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & Record<K, string> {
return keys.every((k) => env[k] !== undefined && env[k] !== '')
} Try / catch
// config throws at import time, so load it dynamically:
let config: Config
try {
config = (await import('./config')).default
} catch (err) {
console.error('link-preview misconfigured:', err instanceof Error ? err.message : err)
process.exit(1)
} Prevention
- Keep an .env-template in the pod directory and copy it fully when deploying
- Validate env presence in CI/deployment pipelines before rollout
- Use consistent naming between config.ts keys and manifest variables
- Add a health check that fails fast when env vars are missing
When it happens
Trigger: Starting pods/link-preview without required environment variables set (e.g. MONGO_URL/REDIS/TIMEOUT per its Config), or a variable present in .env but not loaded into the container process; typos in env names cause undefined lookups.
Common situations: Docker/Kubernetes deployments missing env entries; .env file not mounted or dotenv not loaded; renaming a config key in code while deployment manifests still use the old variable name.
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/f5babe5828142e53.
Report an issue: GitHub.