{"record":{"id":"5c6f5b5944f9b463","repo":"MagicMirrorOrg/MagicMirror","slug":"sitecode-and-provcode-are-required","errorCode":null,"errorMessage":"siteCode and provCode are required","messagePattern":"siteCode and provCode are required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"defaultmodules/weather/providers/envcanada.js","lineNumber":58,"sourceCode":"\t\tthis.onDataCallback = onData;\n\t\tthis.onErrorCallback = onError;\n\t}\n\n\tstart () {\n\t\tif (this.fetcher) {\n\t\t\tthis.fetcher.startPeriodicFetch();\n\t\t}\n\t}\n\n\tstop () {\n\t\tif (this.fetcher) {\n\t\t\tthis.fetcher.clearTimer();\n\t\t}\n\t}\n\n\t#validateConfig () {\n\t\tif (!this.config.siteCode || !this.config.provCode) {\n\t\t\tthrow new Error(\"siteCode and provCode are required\");\n\t\t}\n\t}\n\n\t#initializeFetcher () {\n\t\tthis.currentHour = new Date().toISOString().substring(11, 13);\n\t\tconst indexURL = this.#getIndexUrl();\n\n\t\tthis.fetcher = new HTTPFetcher(indexURL, {\n\t\t\treloadInterval: this.config.updateInterval,\n\t\t\tlogContext: \"weatherprovider.envcanada\"\n\t\t});\n\n\t\tthis.fetcher.on(\"response\", async (response) => {\n\t\t\tif (response.status === 304) return;\n\t\t\ttry {\n\t\t\t\t// Check if hour changed - restart fetcher with new URL\n\t\t\t\tconst newHour = new Date().toISOString().substring(11, 13);\n\t\t\t\tif (newHour !== this.currentHour) {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/MagicMirrorOrg/MagicMirror/blob/4b4a59534f7da01e4030e46029fe9dd649a7675e/defaultmodules/weather/providers/envcanada.js#L40-L76","documentation":"Environment Canada requires a siteCode (the observation site) and provCode (province code) to build its data URL. #validateConfig runs during initialize() and throws when either is falsy. Without both, the provider cannot construct a request to the EC API.","triggerScenarios":"initialize() called with config missing siteCode or provCode, or with empty strings.","commonSituations":"Using lat/lon-style config copied from another provider (envcanada doesn't geocode); not knowing the site code for your city; provCode left as placeholder like 'XX'.","solutions":["Add config.siteCode and config.provCode (e.g. siteCode for your city, provCode like 'ON')","Look up your location's site code from Environment Canada's site list","Make sure values are non-empty strings, not placeholders"],"exampleFix":"// before\nconfig = { type: \"current\" }\n// after\nconfig = { type: \"current\", siteCode: \"s0000458\", provCode: \"ON\" }","handlingStrategy":"validation","validationCode":"function hasEnvCanadaConfig(config) {\n  return typeof config.siteCode === \"string\" && config.siteCode.length > 0\n    && typeof config.provCode === \"string\" && config.provCode.length > 0;\n}\nif (!hasEnvCanadaConfig(config)) throw new Error(\"envcanada needs non-empty siteCode and provCode\");","typeGuard":"const hasSiteConfig = (c) => c != null && typeof c.siteCode === \"string\" && c.siteCode.trim() !== \"\" && typeof c.provCode === \"string\" && c.provCode.trim() !== \"\";","tryCatchPattern":"try {\n  provider.initialize(config);\n} catch (err) {\n  if (err.message === \"siteCode and provCode are required\") {\n    console.error(\"Add envcanada siteCode/provCode to config (see EC site list)\");\n  } else throw err;\n}","preventionTips":["Look up and store your city's site code and province code in config","Don't reuse lat/lon-style config from other providers for envcanada","Reject placeholder values ('XX', '') in a config lint step","Test provider initialization in CI with a known-good siteCode/provCode pair"],"tags":["config","envcanada","validation"],"backgroundTag":"missing-required-config","analyzedSha":"4b4a59534f7da01e4030e46029fe9dd649a7675e","analyzedAt":"2026-08-31T21:49:42.591Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}