{"record":{"id":"ed4e80f5da5ce483","repo":"MagicMirrorOrg/MagicMirror","slug":"latitude-and-longitude-are-required-ed4e80","errorCode":null,"errorMessage":"Latitude and longitude are required","messagePattern":"Latitude and longitude are required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"defaultmodules/weather/providers/weatherapi.js","lineNumber":66,"sourceCode":"\t}\n\n\t#validateConfig () {\n\t\tthis.config.type = `${this.config.type ?? \"\"}`.trim().toLowerCase();\n\n\t\tif (this.config.type === \"forecast\") {\n\t\t\tthis.config.type = \"daily\";\n\t\t}\n\n\t\tif (![\"hourly\", \"daily\", \"current\"].includes(this.config.type)) {\n\t\t\tthrow new Error(`Unknown weather type: ${this.config.type}`);\n\t\t}\n\n\t\tif (!this.config.apiKey || `${this.config.apiKey}`.trim() === \"\") {\n\t\t\tthrow new Error(\"apiKey is required\");\n\t\t}\n\n\t\tif (!Number.isFinite(this.config.lat) || !Number.isFinite(this.config.lon)) {\n\t\t\tthrow new Error(\"Latitude and longitude are required\");\n\t\t}\n\t}\n\n\t#initializeFetcher () {\n\t\tconst url = this.#getUrl();\n\n\t\tthis.fetcher = new HTTPFetcher(url, {\n\t\t\treloadInterval: this.config.updateInterval,\n\t\t\theaders: { \"Cache-Control\": \"no-cache\" },\n\t\t\tlogContext: \"weatherprovider.weatherapi\"\n\t\t});\n\n\t\tthis.fetcher.on(\"response\", async (response) => {\n\t\t\ttry {\n\t\t\t\tconst data = await response.json();\n\t\t\t\tthis.#handleResponse(data);\n\t\t\t} catch (error) {\n\t\t\t\tLog.error(\"[weatherapi] Failed to parse JSON:\", error);","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/defaultmodules/weather/providers/weatherapi.js#L48-L84","documentation":"#validateConfig requires numeric lat and lon for the WeatherAPI.com query URL. It throws this Error when either value is missing or not a finite number (Number.isFinite check rejects strings, undefined, NaN, Infinity).","triggerScenarios":"Module config lacks lat/lon, supplies them as strings (lat: \"52.5\"), sets them to null/undefined, or a location-lookup feature failed to populate them before initialize.","commonSituations":"Using location name instead of coordinates (some providers accept city names, weatherapi provider in MagicMirror does not), copy-pasting coordinates as strings from JSON, lat/lon defined only in a different config section.","solutions":["Add numeric lat and lon to the module config, e.g. lat: 52.52, lon: 13.405.","Remove quotes so values are numbers, not strings.","If coordinates come from another module, ensure they are Number() coerced before provider init.","Verify lat/lon are in decimal degrees (not degrees-minutes-seconds)."],"exampleFix":"// before\nconfig: { weatherProvider: \"weatherapi\", apiKey: \"k\", lat: \"52.52\", lon: \"13.40\" }\n// after\nconfig: { weatherProvider: \"weatherapi\", apiKey: \"k\", lat: 52.52, lon: 13.40 }","handlingStrategy":"validation","validationCode":"const lat = Number(config.lat), lon = Number(config.lon);\nif (!Number.isFinite(lat) || !Number.isFinite(lon) || Math.abs(lat) > 90 || Math.abs(lon) > 180) {\n  throw new Error(`weatherapi: lat/lon must be finite decimal degrees, got ${config.lat}, ${config.lon}`);\n}","typeGuard":"function hasValidCoords(config) {\n  return Number.isFinite(config.lat) && Number.isFinite(config.lon);\n}","tryCatchPattern":null,"preventionTips":["Always store lat/lon as numbers, never quoted strings, in config.","Range-check lat [-90,90] and lon [-180,180] when coordinates come from user input or geocoding.","If geocoding by city name, convert to coordinates before passing to this provider."],"tags":["config","validation","weather","coordinates"],"backgroundTag":"invalid-config-value","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}