{"record":{"id":"18a2942682057f03","repo":"sxyazi/yazi","slug":"invalid-args-in-searchopt","errorCode":null,"errorMessage":"invalid 'args' in SearchOpt","messagePattern":"invalid 'args' in SearchOpt","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-core/src/mgr/search.rs","lineNumber":31,"sourceCode":"\tpub args:    Vec<String>,\n\tpub r#in:    Option<UrlBuf>,\n}\n\nimpl_data_any!(SearchOpt);\n\nimpl TryFrom<ActionCow> for SearchOpt {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {\n\t\tlet r#in = a.take::<UrlBuf>(\"in\").ok();\n\t\tif let Some(u) = &r#in\n\t\t\t&& (!u.is_absolute() || u.is_search())\n\t\t{\n\t\t\tbail!(\"invalid 'in' in SearchOpt\");\n\t\t}\n\n\t\tlet Ok(args) = yazi_shared::shell::unix::split(a.str(\"args\"), false) else {\n\t\t\tbail!(\"invalid 'args' in SearchOpt\");\n\t\t};\n\n\t\tOk(Self {\n\t\t\tvia: a.str(\"via\").parse()?,\n\t\t\tsubject: a.take_first().unwrap_or_default(),\n\t\t\targs: args.0,\n\t\t\tr#in,\n\t\t})\n\t}\n}\n\n// --- Via\n#[derive(Clone, Copy, Debug, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq)]\n#[serde(rename_all = \"kebab-case\")]\n#[strum(serialize_all = \"kebab-case\")]\npub enum SearchVia {\n\tRg,\n\tRga,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-core/src/mgr/search.rs#L13-L49","documentation":"In the same SearchOpt conversion (yazi-core/src/mgr/search.rs:31), the `args` string is split with the Unix shell splitter `yazi_shared::shell::unix::split`. If the string cannot be split (unbalanced quotes or other shell-syntax errors), the conversion bails because the search command arguments are unusable.","triggerScenarios":"Passing an `args` value containing unbalanced quotes or otherwise invalid shell syntax, e.g. `args = '\"unterminated` , so `split(a.str(\"args\"), false)` returns Err.","commonSituations":"Hand-edited yazi.toml search settings with a stray quote, dynamically composed args where a filename containing quotes is interpolated unescaped.","solutions":["Fix the quoting in the `args` string so it is valid shell syntax (balanced quotes).","Escape dynamic values before interpolating them into args, or pass them as separate structured arguments.","Validate the args string with the shell splitter before dispatching the action."],"exampleFix":"// before\nargs = \"--glob '*.log\"   // unbalanced quote\n// after\nargs = \"--glob '*.log'\"","handlingStrategy":"validation","validationCode":"// reuse the same splitter the library uses, before dispatch\nmatch yazi_shared::shell::unix::split(&args_str, false) {\n    Ok(_) => { /* safe to dispatch search with args */ }\n    Err(e) => eprintln!(\"bad args: {e}\"),\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep quotes balanced in `args` strings in config files.","Escape or shell-quote dynamic values (filenames with spaces/quotes) before interpolation.","Run the args through the shell splitter in tests for every config variant."],"tags":["search","shell-parsing","argument-validation"],"backgroundTag":"shell-quote-parse-error","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}