{"record":{"id":"0fd334da65a9b4eb","repo":"badges/shields","slug":"should-not-get-here-due-to-validation","errorCode":null,"errorMessage":"Should not get here due to validation","messagePattern":"Should not get here due to validation","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"services/uptimerobot/uptimerobot-status.service.js","lineNumber":50,"sourceCode":"    status,\n    upMessage = 'up',\n    downMessage = 'down',\n    upColor = 'brightgreen',\n    downColor = 'red',\n  }) {\n    switch (status) {\n      case 0:\n        return { message: 'paused', color: 'yellow' }\n      case 1:\n        return { message: 'not checked yet', color: 'yellowgreen' }\n      case 2:\n        return { message: upMessage, color: upColor }\n      case 8:\n        return { message: 'seems down', color: 'orange' }\n      case 9:\n        return { message: downMessage, color: downColor }\n      default:\n        throw Error('Should not get here due to validation')\n    }\n  }\n\n  async handle(\n    { monitorSpecificKey },\n    {\n      up_message: upMessage,\n      down_message: downMessage,\n      up_color: upColor,\n      down_color: downColor,\n    },\n  ) {\n    const { monitors } = await this.fetch({ monitorSpecificKey })\n    const { status } = monitors[0]\n    return this.constructor.render({\n      status,\n      upMessage,\n      downMessage,","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/uptimerobot/uptimerobot-status.service.js#L32-L68","documentation":"In uptimerobot-status.service.js, render() maps a UptimeRobot monitor status code to a message/color pair via a switch. Codes outside the validated range (0/1/2/8/9) reach the default case, where the service throws this plain Error. It should be unreachable because handle() validates the status value upstream, so it signals an internal invariant violation or an unanticipated API status code.","triggerScenarios":"UptimeRobot API returns a monitor status code not covered by the switch (e.g. a newly introduced status code, or a code like 7 for check-timeout that slipped past validation) so it reaches the default case in render().","commonSituations":"UptimeRobot adds or documents a new status code after this badge was written; a mocked/tested API returns an unexpected integer; upstream validation is loosened during a refactor and an unusual code slips through.","solutions":["Log the actual status code to identify the uncovered value, then add a switch case mapping it to a message/color","Wrap the value in handle()'s validation so unknown codes fall back to a neutral 'unknown' badge state instead of throwing","Catch the error in handle() and render a default 'unknown' response"],"exampleFix":"// before\ncase 9:\n  return { message: downMessage, color: downColor }\ndefault:\n  throw Error('Should not get here due to validation')\n// after\ncase 9:\n  return { message: downMessage, color: downColor }\ndefault:\n  return { message: 'unknown status', color: 'lightgrey' }","handlingStrategy":"try-catch","validationCode":"const KNOWN_STATUSES = [0, 1, 2, 8, 9]\nif (!KNOWN_STATUSES.includes(monitor.status)) {\n  console.warn(`Unrecognized UptimeRobot status: ${monitor.status}`)\n}","typeGuard":"function isKnownUptimeRobotStatus(status) {\n  return [0, 1, 2, 8, 9].includes(status)\n}","tryCatchPattern":"try {\n  return await uptimerobotStatusService.handle(config, props)\n} catch (err) {\n  if (err.message === 'Should not get here due to validation') {\n    return { message: 'unknown status', color: 'lightgrey' }\n  }\n  throw err\n}","preventionTips":["When UptimeRobot documents new status codes, update both validation and the render switch","Add a default-case fallback instead of throwing for unknown codes","Test render() against every documented status code","Monitor for this error in production logs to catch API contract changes early"],"tags":["unhandled-status-code","external-api","invariant-violation"],"backgroundTag":"unhandled-status-code","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}