{"record":{"id":"2eb8189d69a607c5","repo":"hcengineering/platform","slug":"missing-config-for-attributes-missingenv-join-2eb818","errorCode":null,"errorMessage":"Missing config for attributes: ${missingEnv.join(', ')}","messagePattern":"Missing config for attributes: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"services/datalake/pod-datalake/src/config.ts","lineNumber":111,"sourceCode":"    AccountsUrl: process.env.ACCOUNTS_URL,\n    DbUrl: process.env.DB_URL,\n    Buckets: parseBucketsConfig(process.env.BUCKETS),\n    Secure: process.env.SECURE === 'true',\n    Readonly: process.env.READONLY === 'true',\n    Cache: {\n      enabled: process.env.CACHE_ENABLED !== 'false',\n      blobSize: (parseNumber(process.env.CACHE_BLOB_SIZE) ?? 64) * 1024, // Default 64KB\n      blobCount: parseNumber(process.env.CACHE_BLOB_COUNT) ?? 1000\n    },\n    // Configured in megabytes via MAX_FILE_SIZE_MB (default 5120 MB = 5 GiB,\n    // e.g. set to 10240 for 10 GiB).\n    MaxFileSize: (parseNumber(process.env.MAX_FILE_SIZE_MB) ?? 5120) * 1024 * 1024\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":93,"sourceCodeEnd":118,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/services/datalake/pod-datalake/src/config.ts#L93-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Set the listed environment variables in your deployment environment (K8s manifest, docker-compose, .env, CI secrets) before starting the service.","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.","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."],"exampleFix":"// before (env missing)\nMAX_FILE_SIZE_MB=  # unset or invalid\n// after\n# .env\nMAX_FILE_SIZE_MB=5120","handlingStrategy":"validation","validationCode":"// Run before importing the app (e.g. in entrypoint script)\nconst required = ['MAX_FILE_SIZE_MB' /* plus all env vars read in config.ts */];\nconst missing = required.filter((k) => process.env[k] === undefined);\nif (missing.length) {\n  console.error('Missing env vars:', missing.join(', '));\n  process.exit(1);\n}","typeGuard":"function hasEnv<K extends string>(key: K): key is K & keyof NodeJS.ProcessEnv {\n  return process.env[key] !== undefined;\n}","tryCatchPattern":"try {\n  const { default: config } = await import('./src/config.js');\n} catch (e) {\n  console.error(`Config load failed: ${(e as Error).message}`);\n  process.exit(1);\n}","preventionTips":["Keep a checked-in .env.example listing every required var and validate it in CI.","Fail in CI with a config smoke test that imports config.ts with a dummy env.","Document each Config key's env var next to its definition in config.ts."],"tags":["environment","configuration","startup","fail-fast"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}