{"record":{"id":"7dad8939a649f97b","repo":"elkowar/eww","slug":"error-missing-argument-when-creating-window","errorCode":null,"errorMessage":"Error, missing argument '{}' when creating window with id '{}'","messagePattern":"Error, missing argument '(.+?)' when creating window with id '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eww/src/window_arguments.rs","lineNumber":75,"sourceCode":"        let expected_args: HashSet<&String> = window_def.expected_args.iter().map(|x| &x.name.0).collect();\n        let mut local_variables: HashMap<VarName, DynVal> = HashMap::new();\n\n        // Ensure that the arguments passed to the window that are already interpreted by eww (id, screen)\n        // are set to the correct values\n        if expected_args.contains(&String::from(\"id\")) {\n            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":57,"sourceCodeEnd":91,"githubUrl":"https://github.com/elkowar/eww/blob/48f5aa8b379adf29da0b0bb9ca04164f65d8bdaa/crates/eww/src/window_arguments.rs#L57-L91","documentation":"WindowArguments::get_local_window_variables checks that every non-optional argument declared in the window definition (expected_args) is present among the provided local variables/args. If a required argument is missing when creating a window instance, eww bails with this error naming the argument and window id.","triggerScenarios":"Running `eww open <window>` where the window's (defwindow ... expected-args) declares a required attribute that was not supplied — e.g. `eww open bar foo=1` omitting a required arg like `:expected-args \"{idx}\"` with no idx given.","commonSituations":"Windows defined with :expected-args but opened without `eww open window key=value`; widget repetition helpers (windows opened per monitor/workspace) missing the monitor/workspace argument; renamed arguments not updated in the open command.","solutions":["Supply the missing argument: `eww open <window> <arg>=<value>`","Mark the argument optional in the window definition if it is not truly required","Use `eww windows` to inspect the window's expected args and what you passed","Update scripts/autostart configs that open the window to pass all required args"],"exampleFix":"// before\neww open bar\n// after\neww open bar idx=0 monitor=1","handlingStrategy":"validation","validationCode":"const required = windowDef.expectedArgs.filter(a => !a.optional);\nconst missing = required.filter(a => !(a.name in providedArgs));\nif (missing.length) throw new Error(`missing: ${missing.map(a => a.name).join(', ')}`);","typeGuard":"function hasRequiredArgs(def, args) { return def.expectedArgs.every(a => a.optional || a.name in args); }","tryCatchPattern":"try { execSync(`eww open ${win} ${args}`); } catch (e) { if (String(e).includes(\"missing argument\")) { console.error('Supply all required window args, e.g. eww open bar idx=0'); } else { throw e; } }","preventionTips":["Pass every non-optional expected arg on `eww open`","Mark truly optional params with optional in the window definition","Inspect `eww windows` to see declared expected args","Keep autostart/open scripts in sync with window definitions"],"tags":["window","argument","yuck","cli"],"backgroundTag":"missing-required-argument","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"}