MagicMirrorOrg/MagicMirror · error · Error

Invalid grid point data

Error message

Invalid grid point data

What it means

After the points request succeeds, #fetchWeatherGovURLs expects pointsData.properties. If the JSON body lacks properties (or is not JSON/an error envelope), the provider cannot derive forecast URLs and throws "Invalid grid point data".

Solutions

  1. Log pointsData before the throw to see what was actually returned.
  2. Retry later if NWS is degraded — transient payloads can lack properties.
  3. Verify the request URL (api.weather.gov/points/{lat},{lon}) returns properties in a browser.
  4. Update MagicMirror — providers are fixed when NWS changes its schema.

Example fix

// before
if (!pointsData || !pointsData.properties) {
  throw new Error("Invalid grid point data");
}
// after — include the body for diagnosis
if (!pointsData || !pointsData.properties) {
  throw new Error(`Invalid grid point data: ${JSON.stringify(pointsData).slice(0, 200)}`);
}
Defensive patterns

Strategy: type-guard

Validate before calling

// pre-flight the exact endpoint the provider will call
const r = await fetch(`https://api.weather.gov/points/${lat},${lon}`, { headers: { "User-Agent": "MagicMirror" } });
const j = await r.json();
if (!j?.properties) throw new Error("points endpoint lacks properties — NWS degraded or rate limited");

Type guard

function hasGridPoint(d) {
  return !!d && typeof d === "object" && !!d.properties
    && typeof d.properties.forecast === "string";
}

Try / catch

try {
  await provider.initialize();
} catch (err) {
  if (err.message === "Invalid grid point data") {
    Log.warn("weathergov: unusable grid point payload — retrying later");
    scheduleRetry(10 * 60_000);
  } else { throw err; }
}

Prevention

When it happens

Trigger: api.weather.gov returns 200 with an unexpected body: an API error/limit JSON, an HTML error page that still parsed, or an NWS schema change removing/renaming properties.

Common situations: Hitting api.weather.gov rate limits that return 200 with an error body via some proxies/CDNs; edge locations where the API returns an empty property set; running a stale provider against an updated NWS API.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at defaultmodules/weather/providers/weathergov.js:138

		const timeoutId = setTimeout(() => controller.abort(), 120000); // 120 second timeout - DNS can be slow

		try {
			const pointsResponse = await fetch(pointsUrl, {
				signal: controller.signal,
				headers: {
					"User-Agent": "MagicMirror",
					Accept: "application/geo+json"
				}
			});

			if (!pointsResponse.ok) {
				throw new Error(`Failed to fetch grid point: HTTP ${pointsResponse.status}`);
			}

			const pointsData = await pointsResponse.json();

			if (!pointsData || !pointsData.properties) {
				throw new Error("Invalid grid point data");
			}

			// Extract location name
			const relLoc = pointsData.properties.relativeLocation?.properties;
			if (relLoc) {
				this.locationName = `${relLoc.city}, ${relLoc.state}`;
			}

			// Store forecast URLs
			this.forecastURL = `${pointsData.properties.forecast}?units=si`;
			this.forecastHourlyURL = `${pointsData.properties.forecastHourly}?units=si`;
			this.forecastGridDataURL = pointsData.properties.forecastGridData;
			this.observationStationsURL = pointsData.properties.observationStations;

			// Step 2: Get observation station URL
			const stationsResponse = await fetch(this.observationStationsURL, {
				signal: controller.signal,
				headers: {

View on GitHub (pinned to 4b4a59534f)