MagicMirrorOrg/MagicMirror · error · Error
siteCode and provCode are required
Error message
siteCode and provCode are required
What it means
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.
Source
Thrown at defaultmodules/weather/providers/envcanada.js:58
this.onDataCallback = onData;
this.onErrorCallback = onError;
}
start () {
if (this.fetcher) {
this.fetcher.startPeriodicFetch();
}
}
stop () {
if (this.fetcher) {
this.fetcher.clearTimer();
}
}
#validateConfig () {
if (!this.config.siteCode || !this.config.provCode) {
throw new Error("siteCode and provCode are required");
}
}
#initializeFetcher () {
this.currentHour = new Date().toISOString().substring(11, 13);
const indexURL = this.#getIndexUrl();
this.fetcher = new HTTPFetcher(indexURL, {
reloadInterval: this.config.updateInterval,
logContext: "weatherprovider.envcanada"
});
this.fetcher.on("response", async (response) => {
if (response.status === 304) return;
try {
// Check if hour changed - restart fetcher with new URL
const newHour = new Date().toISOString().substring(11, 13);
if (newHour !== this.currentHour) {View on GitHub (pinned to 4b4a59534f)
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
Example fix
// before
config = { type: "current" }
// after
config = { type: "current", siteCode: "s0000458", provCode: "ON" } Defensive patterns
Strategy: validation
Validate before calling
function hasEnvCanadaConfig(config) {
return typeof config.siteCode === "string" && config.siteCode.length > 0
&& typeof config.provCode === "string" && config.provCode.length > 0;
}
if (!hasEnvCanadaConfig(config)) throw new Error("envcanada needs non-empty siteCode and provCode"); Type guard
const hasSiteConfig = (c) => c != null && typeof c.siteCode === "string" && c.siteCode.trim() !== "" && typeof c.provCode === "string" && c.provCode.trim() !== "";
Try / catch
try {
provider.initialize(config);
} catch (err) {
if (err.message === "siteCode and provCode are required") {
console.error("Add envcanada siteCode/provCode to config (see EC site list)");
} else throw err;
} Prevention
- 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
When it happens
Trigger: initialize() called with config missing siteCode or provCode, or with empty strings.
Common situations: 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'.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Latitude and longitude are required
- Unknown weather type: ${this.config.type}
- Latitude and longitude are required
- Module ${index} ("${mod.module}") uses unknown position: "${
- Invalid API response
AI-assisted analysis of MagicMirrorOrg/MagicMirror@4b4a59534f (2026-08-31).
Data as JSON: /api/errors/5c6f5b5944f9b463.
Report an issue: GitHub.