{"record":{"id":"98d73061aa72d598","repo":"MagicMirrorOrg/MagicMirror","slug":"invalid-current-weather-data","errorCode":null,"errorMessage":"Invalid current weather data","messagePattern":"Invalid current weather data","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"defaultmodules/weather/providers/weathergov.js","lineNumber":239,"sourceCode":"\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\t#handleResponse (data) {\n\t\ttry {\n\t\t\tlet weatherData;\n\n\t\t\tswitch (this.config.type) {\n\t\t\t\tcase \"current\":\n\t\t\t\t\tif (!data.properties) {\n\t\t\t\t\t\tthrow new Error(\"Invalid current weather data\");\n\t\t\t\t\t}\n\t\t\t\t\tweatherData = this.#generateWeatherObjectFromCurrentWeather(data.properties);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"forecast\":\n\t\t\t\tcase \"daily\":\n\t\t\t\t\tif (!data.properties || !data.properties.periods) {\n\t\t\t\t\t\tthrow new Error(\"Invalid forecast data\");\n\t\t\t\t\t}\n\t\t\t\t\tweatherData = this.#generateWeatherObjectsFromForecast(data.properties.periods);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"hourly\":\n\t\t\t\t\tif (!data.properties || !data.properties.periods) {\n\t\t\t\t\t\tthrow new Error(\"Invalid hourly data\");\n\t\t\t\t\t}\n\t\t\t\t\tweatherData = this.#generateWeatherObjectsFromHourly(data.properties.periods);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\tthrow new Error(`Unknown weather type: ${this.config.type}`);","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/defaultmodules/weather/providers/weathergov.js#L221-L257","documentation":"#handleResponse switches on this.config.type and validates the fetched data before building the weather object. For \"current\" it requires data.properties; a missing properties object means the latest-observation payload is unusable, so it throws \"Invalid current weather data\".","triggerScenarios":"The /observations/latest endpoint returns JSON without a properties field: an API error envelope, an empty/deprecated station observation, or an NWS response shape change.","commonSituations":"Station temporarily not reporting (properties absent while station is offline); stale observation removed by NWS; rate-limit or error JSON returned with a 200/ok status from a cache layer.","solutions":["Log the raw data around the throw to read any NWS error message in the body.","The provider re-fetches on its interval — wait for the station to resume reporting; if persistent, the station is dead.","Choose a nearby grid point/station with active reporting, or switch type to \"forecast\".","Update MagicMirror if NWS changed the observation schema; check the repo for recent weathergov fixes."],"exampleFix":"// before\ncase \"current\":\n  if (!data.properties) {\n    throw new Error(\"Invalid current weather data\");\n  }\n// after — fall back to skipping this cycle instead of throwing\nif (!data.properties) {\n  Log.error(\"[weathergov] No properties in current observation; skipping\");\n  return;\n}","handlingStrategy":"type-guard","validationCode":"const r = await fetch(`${stationId}/observations/latest`, { headers: { \"User-Agent\": \"MagicMirror\" } });\nconst j = await r.json();\nif (!j?.properties) console.warn(\"Station latest observation unavailable — station may be offline\");","typeGuard":"function hasCurrentObservation(d) {\n  return !!d && typeof d === \"object\" && !!d.properties\n    && typeof d.properties.temperature === \"object\";\n}","tryCatchPattern":"try {\n  await provider.initialize();\n} catch (err) {\n  if (err.message === \"Invalid current weather data\") {\n    Log.warn(\"weathergov: station observation unusable — will retry next cycle\");\n    renderPlaceholder(); // skip this cycle rather than crash the module\n  } else { throw err; }\n}","preventionTips":["Accept that observations/latest can legitimately be empty; handle missing properties gracefully per cycle.","Log the response body on failure to capture NWS error envelopes.","Update MagicMirror when NWS changes the observation schema; prefer forecast mode where current data is optional."],"tags":["api","schema-validation","weather","empty-data"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}