{"record":{"id":"7901e0646fdc040f","repo":"sxyazi/yazi","slug":"invalid-query-in-finddoopt","errorCode":null,"errorMessage":"Invalid 'query' in FindDoOpt","messagePattern":"Invalid 'query' in FindDoOpt","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-core/src/mgr/find.rs","lineNumber":21,"sourceCode":"use yazi_macro::impl_data_any;\nuse yazi_shared::event::ActionCow;\nuse yazi_shim::SStr;\n\n#[derive(Clone, Debug)]\npub struct FindDoOpt {\n\tpub query: SStr,\n\tpub prev:  bool,\n\tpub case:  FilterCase,\n}\n\nimpl_data_any!(FindDoOpt);\n\nimpl TryFrom<ActionCow> for FindDoOpt {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {\n\t\tlet Ok(query) = a.take_first() else {\n\t\t\tbail!(\"Invalid 'query' in FindDoOpt\");\n\t\t};\n\n\t\tOk(Self { query, prev: a.bool(\"previous\"), case: FilterCase::from(&*a) })\n\t}\n}\n","sourceCodeStart":3,"sourceCodeEnd":27,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-core/src/mgr/find.rs#L3-L27","documentation":"Building FindDoOpt from an ActionCow (yazi-core/src/mgr/find.rs:21) requires the first action argument to be the search query string. If the first argument cannot be taken (`a.take_first()` errors), the conversion bails because a find operation without a query is invalid.","triggerScenarios":"Dispatching a `find_do` action with no first argument or a first argument of the wrong type, so `a.take_first()` returns Err and the bail executes.","commonSituations":"Keymap binding like `run = 'find_do'` without the query, or invoking find programmatically via the app API with an omitted query parameter.","solutions":["Provide the query as the first argument of the find_do action, e.g. `find_do 'pattern'`.","Check that the action was constructed with args before dispatching.","In keymaps, prefer `find` for interactive search where the query is typed, reserving `find_do` for explicit queries."],"exampleFix":"// before\nrun = \"find_do\"\n// after\nrun = \"find_do 'TODO'\"","handlingStrategy":"validation","validationCode":"if query.is_empty() {\n    eprintln!(\"find_do requires a query argument\");\n    return;\n}\n// dispatch: find_do '<query>'","typeGuard":"fn has_query(args: &[String]) -> bool {\n    args.first().map(|q| !q.is_empty()).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Use `find` (interactive) when the query is typed at runtime; use `find_do` only with an explicit query.","Quote the query in run strings: `find_do 'TODO'`.","Guard programmatically-built actions to always include the query as first arg."],"tags":["find","action-parsing","argument-validation"],"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-14T05:17:10.506Z"}