{"record":{"id":"f5babe5828142e53","repo":"hcengineering/platform","slug":"missing-config-for-attributes-missingenv-join","errorCode":null,"errorMessage":"Missing config for attributes: ${missingEnv.join(', ')}","messagePattern":"Missing config for attributes: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/link-preview/src/config.ts","lineNumber":44,"sourceCode":"  TimeoutMs?: number\n  MaxImageBytes?: number\n}\n\nconst config: Config = (() => {\n  const params: Partial<Config> = {\n    Port: parseInt(process.env.PORT ?? '4041'),\n    Secret: process.env.SECRET,\n    ServiceID: process.env.SERVICE_ID ?? 'link-preview',\n    UserAgent: process.env.USER_AGENT ?? 'Huly Link Preview Service/1.0',\n    DescriptionMaxSentences: parseInt(process.env.DESCRIPTION_MAX_SENTENCES ?? '3'),\n    DescriptionMaxLength: parseInt(process.env.DESCRIPTION_MAX_LENGTH ?? '200'),\n    TimeoutMs: parseInt(process.env.TIMEOUT ?? '5') * 1000\n  }\n\n  const missingEnv = (Object.keys(params) as Array<keyof Config>).filter((key) => params[key] === undefined)\n\n  if (missingEnv.length > 0) {\n    throw Error(`Missing config for attributes: ${missingEnv.join(', ')}`)\n  }\n\n  return params as Config\n})()\n\nexport default config\n","sourceCodeStart":26,"sourceCodeEnd":51,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/link-preview/src/config.ts#L26-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ntransactor:\n  image: link-preview  # no env\n# after\nenv:\n  - MONGO_URL=mongodb://mongo:27017\n  - REDIS_URL=redis://redis:6379\n  - TIMEOUT=5","handlingStrategy":"validation","validationCode":"const required = ['MONGO_URL', 'REDIS_URL', 'TIMEOUT'] // keys from pods/link-preview Config\nconst missing = required.filter((k) => process.env[k] === undefined)\nif (missing.length > 0) {\n  throw new Error(`Set env vars before starting link-preview: ${missing.join(', ')}`)\n}","typeGuard":"function hasEnv<K extends string>(keys: K[], env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & Record<K, string> {\n  return keys.every((k) => env[k] !== undefined && env[k] !== '')\n}","tryCatchPattern":"// config throws at import time, so load it dynamically:\nlet config: Config\ntry {\n  config = (await import('./config')).default\n} catch (err) {\n  console.error('link-preview misconfigured:', err instanceof Error ? err.message : err)\n  process.exit(1)\n}","preventionTips":["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"],"tags":["configuration","environment-variables","link-preview","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}