{"record":{"id":"b12c46d68e453a8c","repo":"cube-js/cube","slug":"value-input-is-not-valid-for-envname-de","errorCode":null,"errorMessage":"Value \"${input}\" is not valid for ${envName}. ${description}","messagePattern":"Value \"(.+?)\" is not valid for (.+?)\\. (.+?)","errorType":"validation","errorClass":"InvalidConfiguration","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/env.ts","lineNumber":34,"sourceCode":"  description: string = 'Must be a number in seconds or duration string (1s, 1m, 1h).',\n) {\n  if (/^\\d+$/.test(input)) {\n    return parseInt(input, 10);\n  }\n\n  if (input.length > 1) {\n    // eslint-disable-next-line default-case\n    switch (input.slice(-1).toLowerCase()) {\n      case 'h':\n        return parseInt(input.slice(0, -1), 10) * 60 * 60;\n      case 'm':\n        return parseInt(input.slice(0, -1), 10) * 60;\n      case 's':\n        return parseInt(input.slice(0, -1), 10);\n    }\n  }\n\n  throw new InvalidConfiguration(envName, input, description);\n}\n\nexport function convertSizeToBytes(\n  input: string,\n  envName: string,\n  description: string = 'Must be a number in bytes or size string (1kb, 1mb, 1gb).',\n): number {\n  if (/^\\d+$/.test(input)) {\n    return parseInt(input, 10);\n  }\n\n  if (input.length > 2) {\n    switch (input.slice(-2).toLowerCase()) {\n      case 'kb':\n        return parseInt(input.slice(0, -2), 10) * 1024;\n      case 'mb':\n        return parseInt(input.slice(0, -2), 10) * 1024 * 1024;\n      case 'gb':","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/env.ts#L16-L52","documentation":"convertTimeStrToSeconds parses env values as plain seconds (\"30\") or duration strings ending in h/m/s (\"1h\", \"15m\"). If the value matches neither form (or the numeric part is not an integer), it throws InvalidConfiguration naming the env variable and the expected format. This protects Cube from silently misinterpreting durations.","triggerScenarios":"Setting a duration-related env var (consumed via asBoolOrTime/variables, e.g. CUBEJS_SCHEDULED_REFRESH_TIMER or external timeout vars) to something like \"1hr\", \"one hour\", \"1.5h\", \"h\", or an empty string.","commonSituations":"Typos like \"1hr\" or \"90sec\" in .env files; copy-pasting human-readable durations into env config; forgetting a unit suffix entirely; using decimal values like \"0.5h\".","solutions":["Set the env var to a plain integer of seconds (e.g. 3600) or a string ending in h, m, or s with an integer prefix (e.g. 1h, 15m, 30s).","Check for stray quotes, whitespace, or comments inside the .env value.","Convert decimals to whole units (0.5h -> 30m)."],"exampleFix":"// before (.env)\nCUBEJS_SCHEDULED_REFRESH_TIMER=1hr\n\n// after (.env)\nCUBEJS_SCHEDULED_REFRESH_TIMER=1h","handlingStrategy":"validation","validationCode":"const raw = process.env.CUBEJS_SCHEDULED_REFRESH_TIMER;\nif (raw !== undefined && !/^\\d+$/.test(raw) && !/^\\d+[hms]$/i.test(raw)) {\n  throw new Error(`CUBEJS_SCHEDULED_REFRESH_TIMER=\"${raw}\" must be seconds (3600) or a duration like 1h, 15m, 30s.`);\n}","typeGuard":"function isValidTimeStr(v: string): boolean {\n  return /^\\d+$/.test(v) || /^\\d+[hms]$/i.test(v);\n}","tryCatchPattern":"try {\n  startCubeServer();\n} catch (e) {\n  if (e instanceof InvalidConfiguration && e.message.includes('Must be a number in seconds or duration string')) {\n    console.error('Fix the duration env var: use 30, 30s, 15m, or 1h.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Use whole-unit suffixes only: h, m, s (1h, 15m, 30s) — not hr, sec, or min.","Prefer plain integer seconds in env files to avoid suffix mistakes.","Convert decimals to whole units (0.5h -> 30m).","Validate .env values in CI with a small pre-flight script before deploying."],"tags":["configuration","env-var","validation","invalid-configuration"],"backgroundTag":"invalid-env-value","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}