{"record":{"id":"dcab948b2363c2b9","repo":"hcengineering/platform","slug":"missing-config-for-attributes-missingenv-join-dcab94","errorCode":null,"errorMessage":"Missing config for attributes: ${missingEnv.join(', ')}","messagePattern":"Missing config for attributes: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pods/media/src/config.ts","lineNumber":37,"sourceCode":"export interface Config {\n  AccountsUrl: string\n  Secret: string\n  ServiceID: string\n  Partitions: number\n}\n\nconst config: Config = (() => {\n  const params: Partial<Config> = {\n    AccountsUrl: process.env.ACCOUNTS_URL,\n    Secret: process.env.SECRET,\n    ServiceID: process.env.SERVICE_ID ?? 'media',\n    Partitions: parseNumber(process.env.PARTITIONS) ?? 1\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\nfunction parseNumber (str: string | undefined): number | undefined {\n  if (str !== undefined) {\n    const intValue = Number.parseInt(str)\n    if (Number.isInteger(intValue)) {\n      return intValue\n    }\n  }\n}\n\nexport default config\n","sourceCodeStart":19,"sourceCodeEnd":53,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/pods/media/src/config.ts#L19-L53","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nStorage: process.env.STORAGE_URL // undefined if unset -> throws\n// after\nStorage: process.env.STORAGE_URL ?? 'http://localhost:9000'","handlingStrategy":"validation","validationCode":"const required = ['MONGO_URL', 'STORAGE_URL', 'PARTITIONS'] // keys from pods/media Config\nconst missing = required.filter((k) => process.env[k] === undefined)\nif (missing.length > 0) {\n  throw new Error(`media service missing env vars: ${missing.join(', ')}`)\n}","typeGuard":"function isEnvComplete(keys: readonly string[], env: NodeJS.ProcessEnv): boolean {\n  return keys.every((k) => typeof env[k] === 'string' && env[k] !== '')\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('Fix media env config:', err.message)\n    process.exit(1)\n  }\n  throw err\n}","preventionTips":["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"],"tags":["configuration","environment-variables","media","startup"],"backgroundTag":"missing-env-var","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}