sxyazi/yazi · error

Invalid 'query' in FindDoOpt

Error message

Invalid 'query' in FindDoOpt

What it means

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.

Source

Thrown at yazi-core/src/mgr/find.rs:21

use yazi_macro::impl_data_any;
use yazi_shared::event::ActionCow;
use yazi_shim::SStr;

#[derive(Clone, Debug)]
pub struct FindDoOpt {
	pub query: SStr,
	pub prev:  bool,
	pub case:  FilterCase,
}

impl_data_any!(FindDoOpt);

impl TryFrom<ActionCow> for FindDoOpt {
	type Error = anyhow::Error;

	fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
		let Ok(query) = a.take_first() else {
			bail!("Invalid 'query' in FindDoOpt");
		};

		Ok(Self { query, prev: a.bool("previous"), case: FilterCase::from(&*a) })
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Provide the query as the first argument of the find_do action, e.g. `find_do 'pattern'`.
  2. Check that the action was constructed with args before dispatching.
  3. In keymaps, prefer `find` for interactive search where the query is typed, reserving `find_do` for explicit queries.

Example fix

// before
run = "find_do"
// after
run = "find_do 'TODO'"
Defensive patterns

Strategy: validation

Validate before calling

if query.is_empty() {
    eprintln!("find_do requires a query argument");
    return;
}
// dispatch: find_do '<query>'

Type guard

fn has_query(args: &[String]) -> bool {
    args.first().map(|q| !q.is_empty()).unwrap_or(false)
}

Prevention

When it happens

Trigger: 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.

Common situations: Keymap binding like `run = 'find_do'` without the query, or invoking find programmatically via the app API with an omitted query parameter.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/7901e0646fdc040f. Report an issue: GitHub.