{"record":{"id":"e425f1c3ef497f3d","repo":"thedotmack/claude-mem","slug":"invalid-claude-mem-redis-port-value-expected-a","errorCode":null,"errorMessage":"Invalid CLAUDE_MEM_REDIS_PORT=${value}; expected a TCP port","messagePattern":"Invalid CLAUDE_MEM_REDIS_PORT=(.+?); expected a TCP port","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/server/queue/redis-config.ts","lineNumber":74,"sourceCode":"    if (value !== undefined) {\n      return value;\n    }\n  }\n  return SettingsDefaultsManager.get(key);\n}\n\nfunction normalizeRedisMode(value: string): RedisMode {\n  const normalized = value.trim().toLowerCase();\n  if (normalized === 'external' || normalized === 'managed' || normalized === 'docker') {\n    return normalized;\n  }\n  throw new Error(`Invalid CLAUDE_MEM_REDIS_MODE=${value}; expected external, managed, or docker`);\n}\n\nfunction parseRedisPort(value: string): number {\n  const port = Number.parseInt(value, 10);\n  if (!Number.isInteger(port) || port <= 0 || port > 65535) {\n    throw new Error(`Invalid CLAUDE_MEM_REDIS_PORT=${value}; expected a TCP port`);\n  }\n  return port;\n}\n\nfunction sanitizePrefix(value: string): string {\n  return (value.trim() || 'claude_mem').replace(/[^a-zA-Z0-9_-]/g, '_');\n}\n\nfunction connectionFromHost(host: string, port: number): RedisOptions {\n  return {\n    host,\n    port,\n    maxRetriesPerRequest: null,\n    connectTimeout: 1000,\n    lazyConnect: true,\n  };\n}\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/queue/redis-config.ts#L56-L92","documentation":"Thrown by parseRedisPort when CLAUDE_MEM_REDIS_PORT is not a valid TCP port: parseInt must yield an integer in the range 1–65535. The function rejects non-numeric strings, 0, negative numbers, and ports above 65535 (including parseInt truncations it validates against). This guards the Redis connection from being built with an impossible port.","triggerScenarios":"CLAUDE_MEM_REDIS_PORT set to '' , 'abc', '0', '-1', '99999', '65536', or a float-like string '6379.5' (parseInt gives 6379, but 'http://host:port' garbage or '637 9' parse to invalid values). Triggered while getRedisQueueConfig() builds the Redis connection for external/managed modes.","commonSituations":"Pasting a full redis:// URL into the PORT variable instead of just the number; leaving the placeholder empty; port typo like 63790 (out of range is rare, usually it's non-numeric); Windows line endings or stray characters embedded in the env value from a script.","solutions":["Set CLAUDE_MEM_REDIS_PORT to a plain integer between 1 and 65535 (Redis default: 6379)","Remove the variable if you connect via CLAUDE_MEM_REDIS_URL which carries its own port","Strip quotes, whitespace, and any URL prefix so only digits remain","Verify the value with: node -e \"const p=parseInt(process.env.CLAUDE_MEM_REDIS_PORT,10); console.log(Number.isInteger(p)&&p>0&&p<=65535)\""],"exampleFix":"// before (.env)\nCLAUDE_MEM_REDIS_PORT=redis://localhost:6379\n// after\nCLAUDE_MEM_REDIS_PORT=6379","handlingStrategy":"validation","validationCode":"const raw = process.env.CLAUDE_MEM_REDIS_PORT;\nif (raw !== undefined) {\n  const port = Number(raw);\n  if (!Number.isInteger(port) || port < 1 || port > 65535) {\n    throw new Error(`CLAUDE_MEM_REDIS_PORT must be an integer 1-65535; got \"${raw}\"`);\n  }\n}","typeGuard":"function isValidTcpPort(v: unknown): v is number {\n  return typeof v === 'number' && Number.isInteger(v) && v > 0 && v <= 65535;\n}","tryCatchPattern":"try {\n  const config = getRedisQueueConfig();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('CLAUDE_MEM_REDIS_PORT')) {\n    console.error('Set CLAUDE_MEM_REDIS_PORT to a bare integer like 6379; URL goes in CLAUDE_MEM_REDIS_URL');\n  }\n  throw err;\n}","preventionTips":["Only ever put digits in *_PORT variables — full URLs belong in *_URL variables","Validate port range (1-65535) in a startup env schema","Prefer CLAUDE_MEM_REDIS_URL (with embedded port) over separate host/port vars to reduce config surface","Beware parseInt silently truncating; validate the raw string is all digits before parsing"],"tags":["configuration","environment","redis","validation"],"backgroundTag":"invalid-env-var-value","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}