{"record":{"id":"938d8ecd67c35288","repo":"hcengineering/platform","slug":"missing-config-for-attributes-missingenv-join-938d8e","errorCode":null,"errorMessage":"Missing config for attributes: ${missingEnv.join(', ')}","messagePattern":"Missing config for attributes: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/preview/src/config.ts","lineNumber":49,"sourceCode":"}\n\nconst config: Config = (() => {\n  const params: Partial<Config> = {\n    Port: parseInt(process.env.PORT ?? '4040'),\n    Secret: process.env.SECRET,\n    ServiceID: process.env.SERVICE_ID ?? 'preview',\n    Cache: {\n      enabled: process.env.CACHE_ENABLED !== 'false',\n      cachePath: process.env.CACHE_PATH,\n      cacheSize: parseInt(process.env.CACHE_SIZE ?? '1024') * 1024 * 1024,\n      gcInterval: parseInt(process.env.CACHE_GC_INTERVAL ?? '300') * 1000\n    }\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":31,"sourceCodeEnd":56,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/preview/src/config.ts#L31-L56","documentation":"The preview service (pods/preview) assembles its Config from environment variables and, as a fail-fast check, throws at module load if any required entry is undefined. It never starts the service with incomplete configuration, since previewing depends on storage/workspace/queue settings.","triggerScenarios":"Starting pods/preview without all required env variables from its Config; new config keys introduced in an upgrade but absent in existing deployment manifests; dotenv/.env not loaded so all lookups return undefined.","commonSituations":"Upgrading the platform and the deployment was not updated with new required variables; local dev run without the project .env; typo'd or mis-cased env names in Kubernetes yaml.","solutions":["Set the environment variables named in the error message and restart the service","Compare your deployment env against pods/preview/src/config.ts (or its .env-template) for the full required set","Ensure the .env file is mounted/loaded in the container runtime","After platform upgrades, review config.ts changes and add any newly required variables to manifests"],"exampleFix":"# before\nkubectl set env deploy/preview MONGO_URL=...   # PARTITIONS/STORAGE still missing\n# after\nkubectl set env deploy/preview MONGO_URL=... STORAGE_URL=... PARTITIONS=1 SECRETS=... TOKENS=...","handlingStrategy":"validation","validationCode":"const required = ['MONGO_URL', 'STORAGE_URL', 'SECRETS', 'TOKENS'] // keys from pods/preview Config\nconst missing = required.filter((k) => process.env[k] === undefined)\nif (missing.length > 0) {\n  throw new Error(`preview service missing env vars: ${missing.join(', ')}`)\n}","typeGuard":"function envPresent(keys: readonly string[], env: NodeJS.ProcessEnv): env is NodeJS.ProcessEnv & Record<string, string> {\n  return keys.every((k) => env[k] !== undefined)\n}","tryCatchPattern":"let config: Config\ntry {\n  config = (await import('./config')).default\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Missing config for attributes')) {\n    console.error('preview startup aborted - fix env:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["Mirror all variables from pods/preview .env-template into deployment manifests","After upgrades, diff config.ts against your env and add new keys","Ensure .env files are mounted and loaded before module import","Gate deployments on an env-completeness check in CI"],"tags":["configuration","environment-variables","preview","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}