{"record":{"id":"5587ebda29245887","repo":"MagicMirrorOrg/MagicMirror","slug":"http-response-status","errorCode":null,"errorMessage":"HTTP ${response.status}","messagePattern":"HTTP \\$\\{response\\.status\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"defaultmodules/weather/providers/envcanada.js","lineNumber":122,"sourceCode":"\t\t\t\t\tthis.onErrorCallback({\n\t\t\t\t\t\tmessage: error.message,\n\t\t\t\t\t\ttranslationKey: \"MODULE_ERROR_UNSPECIFIED\"\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.fetcher.on(\"error\", (errorInfo) => {\n\t\t\tif (this.onErrorCallback) {\n\t\t\t\tthis.onErrorCallback(errorInfo);\n\t\t\t}\n\t\t});\n\t}\n\n\tasync #fetchCityPage (url) {\n\t\ttry {\n\t\t\tconst response = await fetch(url);\n\t\t\tif (!response.ok) throw new Error(`HTTP ${response.status}`);\n\n\t\t\tconst xml = await response.text();\n\t\t\tconst weatherData = this.#parseWeatherData(xml);\n\n\t\t\tif (this.onDataCallback) {\n\t\t\t\tthis.onDataCallback(weatherData);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tLog.error(\"[envcanada] Fetch city page error:\", error);\n\t\t\tif (this.onErrorCallback) {\n\t\t\t\tthis.onErrorCallback({\n\t\t\t\t\tmessage: \"Failed to fetch city data\",\n\t\t\t\t\ttranslationKey: \"MODULE_ERROR_UNSPECIFIED\"\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/defaultmodules/weather/providers/envcanada.js#L104-L140","documentation":"#fetchCityPage performs fetch(url) and throws 'HTTP <status>' when response.ok is false (any status outside 200–299). It surfaces the HTTP status of a failed city-page XML request so the caller sees the server's rejection code via the provider's error callback.","triggerScenarios":"Environment Canada returns 404 for a bad siteCode/provCode URL, 403 (blocked/rate limited), 5xx server error, or 301/redirect handled as non-ok.","commonSituations":"Wrong siteCode producing a dead URL; EC service outage; corporate proxy blocking the request; network change mid-session.","solutions":["Check the status code in the error: 404 → verify siteCode/provCode form a valid URL; 403 → check for IP blocking; 5xx → retry later","curl the constructed index/city URL and inspect the response","Confirm network/proxy allows requests to weather.gc.ca","The provider's fetcher timer will retry on the next interval — verify it recovers after upstream heals"],"exampleFix":"// before\n{ siteCode: \"s0009999\", provCode: \"ZZ\" } // 404\n// after\n{ siteCode: \"s0000458\", provCode: \"ON\" } // 200","handlingStrategy":"retry","validationCode":"const url = /* construct the same city-page URL the provider builds */;\nconst pre = await fetch(url);\nif (!pre.ok) console.warn(`EC endpoint unhealthy: HTTP ${pre.status} — fix siteCode/provCode or wait for recovery`);","typeGuard":null,"tryCatchPattern":"provider.setCallbacks(\n  (data) => render(data),\n  (err) => {\n    const m = /^HTTP (\\d+)$/.exec(err.message || \"\");\n    if (m) {\n      const status = Number(m[1]);\n      if (status === 404) fixSiteConfig();\n      else if (status >= 500 || status === 429) retryWithBackoff();\n    }\n  }\n);","preventionTips":["Validate siteCode/provCode by curling the generated URL once at deploy time","Treat 4xx as config bugs and 5xx/429 as transient (backoff retry)","Ensure proxies/firewalls allow weather.gc.ca","Rely on the provider's refresh timer to self-heal after upstream outages"],"tags":["http","network","envcanada"],"backgroundTag":"http-error-status","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}