{"record":{"id":"65fe795ed4cb9567","repo":"sxyazi/yazi","slug":"argument-not-found","errorCode":null,"errorMessage":"argument not found: {:?}","messagePattern":"argument not found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-shared/src/event/action.rs","lineNumber":122,"sourceCode":"\t\t}\n\t\tself\n\t}\n\n\tpub fn with_replier(mut self, tx: impl Into<Replier>) -> Self {\n\t\tself.args.insert(\"replier\".into(), Data::Any(Box::new(tx.into())));\n\t\tself\n\t}\n\n\t// --- Get\n\tpub fn get<'a, T>(&'a self, name: impl Into<DataKey>) -> Result<T>\n\twhere\n\t\tT: TryFrom<&'a Data>,\n\t\tT::Error: Into<anyhow::Error>,\n\t{\n\t\tlet name = name.into();\n\t\tmatch self.args.get(&name) {\n\t\t\tSome(data) => data.try_into().map_err(Into::into),\n\t\t\tNone => bail!(\"argument not found: {:?}\", name),\n\t\t}\n\t}\n\n\tpub fn str(&self, name: impl Into<DataKey>) -> &str { self.get(name).unwrap_or_default() }\n\n\tpub fn bool(&self, name: impl Into<DataKey>) -> bool { self.get(name).unwrap_or(false) }\n\n\tfn any<T: 'static>(&self, name: impl Into<DataKey>) -> Option<&T> {\n\t\tself.args.get(&name.into())?.as_any()\n\t}\n\n\tpub fn replier(&self) -> Option<&Replier> { self.any(\"replier\") }\n\n\tpub fn first<'a, T>(&'a self) -> Result<T>\n\twhere\n\t\tT: TryFrom<&'a Data>,\n\t\tT::Error: Into<anyhow::Error>,\n\t{","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-shared/src/event/action.rs#L104-L140","documentation":"`Action::get` looks up a named argument in the action's argument map and tries to convert it to the requested type T. If no argument with that key exists, it bails with \"argument not found: {name}\" (the key is Debug-formatted). Unlike the convenience accessors `str()` and `bool()`, `get()` propagates missing keys as errors rather than defaulting.","triggerScenarios":"Calling `action.get::<T>(\"some_key\")` where the emitting side never set \"some_key\" in the action's args, or the key name/key-casing differs between sender and receiver; also when the argument exists but cannot convert to T (that yields the conversion error instead).","commonSituations":"Yazi plugin/config keymap bindings invoking commands with missing arguments (e.g. a `spot`/`peek`/`fetch` call that omits an option the Rust handler reads); renamed or typo'd argument keys after an upgrade; Lua side passing arguments under different names than the Rust side expects.","solutions":["Use `action.str(name)` or `action.bool(name)` if a default (\"\"/false) is acceptable instead of `get()`.","Check the sender (keymap config, Lua plugin call) and include the missing argument with the exact key name.","Verify key spelling/case against the handler's expected `DataKey`.","After version upgrades, diff the plugin's emitted args against the handler's read args — names may have changed."],"exampleFix":"// before\nlet url: Url = action.get(\"url\")?; // panics into Err if key absent\n// after\nlet url: Option<Url> = action.args.get(\"url\").and_then(|d| d.clone().try_into().ok());\nlet Some(url) = url else { anyhow::bail!(\"'url' argument is required\") };","handlingStrategy":"validation","validationCode":"fn has_arg(action: &Action, name: &str) -> bool {\n    action.args.get(name).is_some()\n}","typeGuard":null,"tryCatchPattern":"let url: Url = match action.get(\"url\") {\n    Ok(u) => u,\n    Err(e) => { tracing::warn!(\"missing/invalid 'url' arg: {e}\"); return Ok(()); }\n};","preventionTips":["Keep sender and receiver argument key names in a shared constant or documented list.","Prefer `str()`/`bool()` accessors when a default is acceptable.","After upgrades, diff emitted command args vs handler reads.","Validate keymap config entries at load time for required command arguments."],"tags":["rust","arguments","event","yazi-shared"],"backgroundTag":"missing-required-argument","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}