{"record":{"id":"0d6a2c3dd44143e9","repo":"MagicMirrorOrg/MagicMirror","slug":"response-statustext","errorCode":null,"errorMessage":"response.statusText","messagePattern":"response\\.statusText","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"js/node_helper.js","lineNumber":139,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthis.socketNotificationReceived(notification, payload);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Check the status of a fetch response.\n\t * @param {Response} response The fetch response.\n\t * @returns {Response} The fetch response if ok.\n\t */\n\tstatic checkFetchStatus (response) {\n\t\t// response.status >= 200 && response.status < 300\n\t\tif (response.ok) {\n\t\t\treturn response;\n\t\t} else {\n\t\t\tthrow Error(response.statusText);\n\t\t}\n\t}\n\n\t/**\n\t * Look at the specified error and return an appropriate error type, that\n\t * can be translated to a detailed error message\n\t * @param {Error} error the error from fetching something\n\t * @returns {string} the string of the detailed error message in the translations\n\t */\n\tstatic checkFetchError (error) {\n\t\tlet error_type = \"MODULE_ERROR_UNSPECIFIED\";\n\t\tif (error.code === \"EAI_AGAIN\") {\n\t\t\terror_type = \"MODULE_ERROR_NO_CONNECTION\";\n\t\t} else {\n\t\t\tconst message = typeof error.message === \"string\" ? error.message.toLowerCase() : \"\";\n\t\t\tif (message.includes(\"unauthorized\") || message.includes(\"http 401\") || message.includes(\"http 403\")) {\n\t\t\t\terror_type = \"MODULE_ERROR_UNAUTHORIZED\";\n\t\t\t}","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/js/node_helper.js#L121-L157","documentation":"NodeHelper.checkFetchStatus is a fetch response filter: if response.ok is false (HTTP status outside 200-299) it throws an Error whose message is response.statusText. Because it uses statusText (which may be an empty string in HTTP/2 or Node fetch), the thrown error can be uninformative; the status code itself is not included.","triggerScenarios":"Any fetch().then(NodeHelper.checkFetchStatus) chain where the server responds with a non-2xx status: 404 for a wrong URL, 401/403 for missing credentials, 500 for server errors, 429 rate limiting.","commonSituations":"Modules fetching remote APIs that changed endpoints; missing API keys causing 401; typos in URLs giving 404; servers returning empty statusText (Node fetch/HTTP2) so the error message is blank.","solutions":["Fix the URL/endpoint so the request returns a 2xx status","Check authentication: supply the required API key/token for 401/403 responses","Wrap the fetch chain in try/catch (or .catch) and log response.status for diagnosis","Prefer logging status and statusText explicitly instead of relying on statusText alone"],"exampleFix":"// before\nconst res = await fetch(url).then(NodeHelper.checkFetchStatus);\n// after\nconst res = await fetch(url);\nif (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);\nreturn res;","handlingStrategy":"try-catch","validationCode":"const res = await fetch(url);\nif (!res.ok) {\n  throw new Error(`Request failed with HTTP status ${res.status}`);\n}","typeGuard":"function isOkResponse(res) {\n  return typeof res === \"object\" && res !== null && res.ok === true;\n}","tryCatchPattern":"try {\n  const res = await fetch(url).then(NodeHelper.checkFetchStatus);\n  // use res\n} catch (err) {\n  Log.error(`Fetch failed: ${err.message || \"non-2xx response (empty statusText)\"}`);\n}","preventionTips":["Never rely on statusText alone; it is often empty in HTTP/2 and Node fetch","Log res.status explicitly when a fetch fails","Check API keys and endpoint URLs when seeing 401/403/404 errors","Handle 429 rate limits with backoff"],"tags":["http","fetch","error-handling"],"backgroundTag":"http-non-2xx-response","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}