sxyazi/yazi · error · anyhow::Error

Invalid 'opt' in ShowForm

Error message

Invalid 'opt' in ShowForm

What it means

The input component's show form mirrors the completion one: ShowForm::try_from takes an attached "opt" value (an InputOpt) from the Action. An action without that attachment fails with "Invalid 'opt' in ShowForm". FromLua/IntoLua are intentionally unsupported, so the form must come from Rust-side construction or a properly populated action.

Source

Thrown at yazi-parser/src/input/show.rs:19

use anyhow::anyhow;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_shared::event::ActionCow;
use yazi_widgets::input::InputOpt;

#[derive(Debug, Default)]
pub struct ShowForm {
	pub opt: InputOpt,
}

impl From<InputOpt> for ShowForm {
	fn from(opt: InputOpt) -> Self { Self { opt } }
}

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

	fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
		Ok(Self { opt: a.take_any("opt").ok_or_else(|| anyhow!("Invalid 'opt' in ShowForm"))? })
	}
}

impl FromLua for ShowForm {
	fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
}

impl IntoLua for ShowForm {
	fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
}

View on GitHub (pinned to 94abcfa92f)

Solutions

  1. Construct the form directly: ShowForm::from(input_opt)
  2. When emitting an action, always attach the option with .with_any("opt", opt)
  3. Audit for earlier take_any("opt") calls on the same action

Example fix

// before
let form = ShowForm::try_from(action)?; // action has no "opt"

// after
let form = ShowForm::from(opt); // construct directly from InputOpt
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the action carries the option before conversion:
ensure!(action.get::<InputOpt>("opt").is_some(), "show action requires an attached opt");
let form = ShowForm::try_from(action)?;

Prevention

When it happens

Trigger: Emitting the input show action without .with_any("opt", input_opt), or double-taking the "opt" key so the value is gone when the TryFrom conversion runs.

Common situations: Plugins opening the input prompt by emitting raw actions; code paths refactored so another consumer drains the attachment first.

Related errors


AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16). Data as JSON: /api/errors/0fbee5f64cee34c6. Report an issue: GitHub.