MagicMirrorOrg/MagicMirror · error · Error

HTTP ${response.status}

Error message

HTTP ${response.status}

What it means

#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.

Source

Thrown at defaultmodules/weather/providers/envcanada.js:122

					this.onErrorCallback({
						message: error.message,
						translationKey: "MODULE_ERROR_UNSPECIFIED"
					});
				}
			}
		});

		this.fetcher.on("error", (errorInfo) => {
			if (this.onErrorCallback) {
				this.onErrorCallback(errorInfo);
			}
		});
	}

	async #fetchCityPage (url) {
		try {
			const response = await fetch(url);
			if (!response.ok) throw new Error(`HTTP ${response.status}`);

			const xml = await response.text();
			const weatherData = this.#parseWeatherData(xml);

			if (this.onDataCallback) {
				this.onDataCallback(weatherData);
			}
		} catch (error) {
			Log.error("[envcanada] Fetch city page error:", error);
			if (this.onErrorCallback) {
				this.onErrorCallback({
					message: "Failed to fetch city data",
					translationKey: "MODULE_ERROR_UNSPECIFIED"
				});
			}
		}
	}

View on GitHub (pinned to 4b4a59534f)

Solutions

  1. Check the status code in the error: 404 → verify siteCode/provCode form a valid URL; 403 → check for IP blocking; 5xx → retry later
  2. curl the constructed index/city URL and inspect the response
  3. Confirm network/proxy allows requests to weather.gc.ca
  4. The provider's fetcher timer will retry on the next interval — verify it recovers after upstream heals

Example fix

// before
{ siteCode: "s0009999", provCode: "ZZ" } // 404
// after
{ siteCode: "s0000458", provCode: "ON" } // 200
Defensive patterns

Strategy: retry

Validate before calling

const url = /* construct the same city-page URL the provider builds */;
const pre = await fetch(url);
if (!pre.ok) console.warn(`EC endpoint unhealthy: HTTP ${pre.status} — fix siteCode/provCode or wait for recovery`);

Try / catch

provider.setCallbacks(
  (data) => render(data),
  (err) => {
    const m = /^HTTP (\d+)$/.exec(err.message || "");
    if (m) {
      const status = Number(m[1]);
      if (status === 404) fixSiteConfig();
      else if (status >= 500 || status === 429) retryWithBackoff();
    }
  }
);

Prevention

When it happens

Trigger: Environment Canada returns 404 for a bad siteCode/provCode URL, 403 (blocked/rate limited), 5xx server error, or 301/redirect handled as non-ok.

Common situations: Wrong siteCode producing a dead URL; EC service outage; corporate proxy blocking the request; network change mid-session.

Related errors


AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31). Data as JSON: /api/errors/5587ebda29245887. Report an issue: GitHub.