{"record":{"id":"e85a6b65de92ab02","repo":"elkowar/eww","slug":"variables-unexpectedly-defined-when-creating-wi","errorCode":null,"errorMessage":"variables {} unexpectedly defined when creating window with id '{}'","messagePattern":"variables (.+?) unexpectedly defined when creating window with id '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/window_arguments.rs","lineNumber":81,"sourceCode":"            local_variables.insert(VarName::from(\"id\"), DynVal::from(self.instance_id.clone()));\n        }\n        if self.monitor.is_some() && expected_args.contains(&String::from(\"screen\")) {\n            let mon_dyn = DynVal::from(&self.monitor.clone().unwrap());\n            local_variables.insert(VarName::from(\"screen\"), mon_dyn);\n        }\n\n        local_variables.extend(self.args.clone());\n\n        for attr in &window_def.expected_args {\n            let name = VarName::from(attr.name.clone());\n            if !local_variables.contains_key(&name) && !attr.optional {\n                bail!(\"Error, missing argument '{}' when creating window with id '{}'\", attr.name, self.instance_id);\n            }\n        }\n\n        if local_variables.len() != window_def.expected_args.len() {\n            let unexpected_vars: Vec<_> = local_variables.keys().filter(|&n| !expected_args.contains(&n.0)).cloned().collect();\n            bail!(\n                \"variables {} unexpectedly defined when creating window with id '{}'\",\n                unexpected_vars.join(\", \"),\n                self.instance_id,\n            );\n        }\n\n        Ok(local_variables)\n    }\n}\n","sourceCodeStart":63,"sourceCodeEnd":91,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/window_arguments.rs#L63-L91","documentation":"After verifying required args, get_local_window_variables compares the count of provided local variables against the window's expected_args; extra variables not declared as expected args trigger this error listing the unexpected names. Eww windows only accept arguments they declare.","triggerScenarios":"Calling `eww open <window> extra=...` with keys not present in the window's expected-args (or local_variables built from window defaults plus args), making local_variables.len() exceed expected_args.len().","commonSituations":"Typos in argument names so they don't match any expected arg; passing args to a window that declares none; stale open scripts after the window definition changed; duplicate args causing count mismatch.","solutions":["Remove the extra key=value pairs from the `eww open` command","Declare the extra arguments via :expected-args in the window definition","Fix typos so each provided argument matches a declared expected arg","Deduplicate arguments in wrapper scripts that build the open command"],"exampleFix":"// before\neww open bar idx=0 colour=red   ; colour not in :expected-args\n// after\n(defwindow bar :expected-args \"(idx colour)\" ...)\neww open bar idx=0 colour=red","handlingStrategy":"validation","validationCode":"const declared = new Set(windowDef.expectedArgs.map(a => a.name));\nconst extra = Object.keys(providedArgs).filter(k => !declared.has(k));\nif (extra.length) throw new Error(`undeclared args: ${extra.join(', ')}`);","typeGuard":"function onlyDeclaredArgs(def, args) {\n  return Object.fromEntries(Object.entries(args).filter(([k]) => def.expectedArgs.some(a => a.name === k)));\n}","tryCatchPattern":"try { execSync(`eww open ${win} ${args}`); } catch (e) { if (String(e).includes('unexpectedly defined')) { console.error('Remove undeclared args or add them to :expected-args'); } else { throw e; } }","preventionTips":["Only pass arguments declared in :expected-args","Fix typos in argument names so they match declarations","Update open scripts when window definitions change","Deduplicate key=value pairs in generated open commands"],"tags":["window","argument","yuck","cli"],"backgroundTag":"invalid-argument-value","analyzedSha":"48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa","analyzedAt":"2026-09-08T03:13:26.897Z","contentChangedAt":"2026-09-08T03:13:26.897Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}