{"record":{"id":"1db2c9f6926174a6","repo":"sxyazi/yazi","slug":"invalid-in-in-searchopt","errorCode":null,"errorMessage":"invalid 'in' in SearchOpt","messagePattern":"invalid 'in' in SearchOpt","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-core/src/mgr/search.rs","lineNumber":27,"sourceCode":"#[derive(Clone, Debug)]\npub struct SearchOpt {\n\tpub via:     SearchVia,\n\tpub subject: SStr,\n\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\")]","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-core/src/mgr/search.rs#L9-L45","documentation":"SearchOpt's TryFrom (yazi-core/src/mgr/search.rs:27) accepts an optional `in` URL, but if present it must be an absolute URL and not itself a search URL. A relative URL or a URL produced by a previous search violates the invariant, so the conversion bails.","triggerScenarios":"Passing `in` as a relative path (not absolute) or as a search-kind URL (`u.is_search()`), e.g. reusing the current search result URL as the search root.","commonSituations":"Plugin or keymap code passing the current directory as a relative string (`.` or `~/...` unexpanded), or chaining searches where the target is a prior search URL instead of a real directory.","solutions":["Pass an absolute, non-search URL for `in`, e.g. resolve it against the current tab's cwd with `Url::from_absolute_path` or use `tab.cwd()`.","Expand `~` and relative segments to an absolute path before constructing the action.","Drop the `in` argument entirely to let the search default to the current directory."],"exampleFix":"// before\n{ run = \"search rg; --in=.'\" }\n// after\n{ run = \"search rg;\" }  // or supply an absolute path: --in=/home/user/project","handlingStrategy":"validation","validationCode":"fn valid_search_root(u: Option<&Url>) -> bool {\n    match u {\n        None => true,\n        Some(u) => u.is_absolute() && !u.is_search(),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve `in` against tab cwd and expand `~` before passing it.","Never reuse a search-result URL as a search root.","Omit `in` to default to the current directory."],"tags":["search","url-validation","action-parsing"],"backgroundTag":"invalid-url-argument","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}