{"record":{"id":"12f9620e47631a80","repo":"MagicMirrorOrg/MagicMirror","slug":"apikey-is-required","errorCode":null,"errorMessage":"apiKey is required","messagePattern":"apiKey is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"defaultmodules/weather/providers/weatherapi.js","lineNumber":62,"sourceCode":"\tstop () {\n\t\tif (this.fetcher) {\n\t\t\tthis.fetcher.clearTimer();\n\t\t}\n\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 {","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/defaultmodules/weather/providers/weatherapi.js#L44-L80","documentation":"WeatherAPI.com is a commercial API that requires an API key. #validateConfig throws this when config.apiKey is missing, null, or consists only of whitespace, aborting initialize before any network call is made.","triggerScenarios":"apiKey not set in module config, set to empty string \"\" or \"   \", or set to a non-string falsy value (0, false, null) when the module initializes.","commonSituations":"Fresh MagicMirror install with a sample weather config and no key; key stored in an env var or custom.js that fails to resolve to a non-empty string; users confusing weatherapi.com's key with an OpenWeatherMap key.","solutions":["Sign up at weatherapi.com and put the returned key in config: { apiKey: \"<your-key>\" }.","If the key comes from an env/config file, verify it resolves to a non-empty trimmed string (Log the length, never the value).","Make sure you are using a weatherapi.com key, not a key from a different provider.","Restart MagicMirror after adding the key so the module re-initializes."],"exampleFix":"// before\nconfig: {\n  weatherProvider: \"weatherapi\",\n  type: \"current\"\n}\n// after\nconfig: {\n  weatherProvider: \"weatherapi\",\n  type: \"current\",\n  apiKey: \"abc123yourkey\"\n}","handlingStrategy":"validation","validationCode":"if (typeof config.apiKey !== \"string\" || config.apiKey.trim() === \"\") {\n  throw new Error(\"weatherapi: set apiKey in the module config before starting MagicMirror\");\n}","typeGuard":"function hasApiKey(config) {\n  return typeof config.apiKey === \"string\" && config.apiKey.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Provision the key via an untracked config file or env var and assert it is non-empty at startup.","Never commit keys; use a placeholder check in CI.","Confirm the key is activated in the weatherapi.com dashboard before deploying."],"tags":["config","api-key","weather","missing-credentials"],"backgroundTag":"missing-api-key","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}