{"record":{"id":"cc554196be395843","repo":"thedotmack/claude-mem","slug":"invalid-envname-using-default","errorCode":null,"errorMessage":"Invalid ${envName}, using default","messagePattern":"Invalid (.+?), using default","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/shared/worker-utils.ts","lineNumber":31,"sourceCode":"// Imported from ProcessManager.js directly (not the infrastructure barrel):\n// tests mock the barrel module wholesale, and the resolver must stay real.\n// ProcessManager imports nothing from worker-utils, so no cycle.\nimport { resolveWorkerRuntimePath } from \"../services/infrastructure/ProcessManager.js\";\nimport { acquireSpawnLock, releaseSpawnLock } from \"./worker-spawn-gate.js\";\nimport { killProcessTree } from \"./kill-process-tree.js\";\n\nfunction readTimeoutEnv(\n  envName: string,\n  defaultValue: number,\n  bounds: { min: number; max: number }\n): number {\n  const envVal = process.env[envName];\n  if (envVal) {\n    const parsed = parseInt(envVal, 10);\n    if (Number.isFinite(parsed) && parsed >= bounds.min && parsed <= bounds.max) {\n      return parsed;\n    }\n    logger.warn('SYSTEM', `Invalid ${envName}, using default`, {\n      value: envVal, min: bounds.min, max: bounds.max\n    });\n  }\n  return defaultValue;\n}\n\nconst HEALTH_CHECK_TIMEOUT_MS = readTimeoutEnv(\n  'CLAUDE_MEM_HEALTH_TIMEOUT_MS',\n  getTimeout(HOOK_TIMEOUTS.HEALTH_CHECK),\n  { min: 500, max: 300000 }\n);\n\nconst HOOK_READINESS_TIMEOUT_MS = readTimeoutEnv(\n  'CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS',\n  getTimeout(HOOK_TIMEOUTS.HOOK_READINESS_WAIT),\n  { min: 0, max: 300000 }\n);\n","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/shared/worker-utils.ts#L13-L49","documentation":"readTimeoutEnv parses worker timeout env vars (e.g. CLAUDE_MEM_HEALTH_TIMEOUT_MS) as integers and bounds-checks them against [min, max]. If the value is non-numeric or outside bounds, it warns with the value and the bounds, then falls back to the default derived from HOOK_TIMEOUTS.","triggerScenarios":"Setting CLAUDE_MEM_HEALTH_TIMEOUT_MS (or a sibling timeout var) to a non-integer like \"2s\"/\"abc\", or a number outside the logged min/max window (e.g. 100 when min is 500, or 999999 above max).","commonSituations":"Copying \"10s\"-style values from docs into env vars; confusing seconds with milliseconds; pasting values from older versions with different bounds.","solutions":["Set the variable to a bare integer in milliseconds within the logged min/max (e.g. 10000 for ten seconds).","Or unset the variable entirely to inherit the default.","Double-check for stray quotes or units in the env value."],"exampleFix":"# before\nexport CLAUDE_MEM_HEALTH_TIMEOUT_MS=10s\n\n# after\nexport CLAUDE_MEM_HEALTH_TIMEOUT_MS=10000","handlingStrategy":"validation","validationCode":"const parsed = parseInt(process.env.CLAUDE_MEM_HEALTH_TIMEOUT_MS ?? '', 10);\nif (!Number.isFinite(parsed) || parsed < 500 || parsed > 300000) {\n  // fall back to default; do not ship the raw value further\n}","typeGuard":"const isBoundedInt = (v: string, min: number, max: number): v is `${number}` => {\n  const n = parseInt(v, 10);\n  return Number.isFinite(n) && n >= min && n <= max;\n};","tryCatchPattern":null,"preventionTips":["Set timeout env vars as bare integers in milliseconds (10000, not '10s').","Lint shell profiles and CI env blocks for unit suffixes in numeric env vars.","Remember bounds are enforced (e.g. 500..300000); values outside them silently become defaults."],"tags":["env-var","timeout","configuration","claude-mem"],"backgroundTag":"invalid-env-var-value","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}