sxyazi/yazi · error · anyhow::Error

Invalid 'opt' in ShowForm

Error message

Invalid 'opt' in ShowForm

What it means

The completion component's show form is rebuilt from an in-process Action: ShowForm::try_from takes the attached "opt" value (a CmpOpt) with take_any("opt"). If the action carries no such attachment, conversion fails with "Invalid 'opt' in ShowForm". The form is never constructed from Lua values (FromLua/IntoLua are deliberately unsupported).

Source

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

use anyhow::anyhow;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_core::cmp::CmpOpt;
use yazi_shared::event::ActionCow;

#[derive(Clone, Debug)]
pub struct ShowForm {
	pub opt: CmpOpt,
}

impl From<CmpOpt> for ShowForm {
	fn from(opt: CmpOpt) -> 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. Build the form directly from the option: ShowForm::from(cmp_opt) instead of going through an Action
  2. If emitting an action, attach the value: .with_any("opt", opt)
  3. Reuse the existing input/completion plumbing rather than hand-emitting internal actions

Example fix

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

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

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Emitting the completion show action manually — from a plugin or custom key binding — without attaching a CmpOpt, or a code path that already consumed the "opt" value before the TryFrom runs.

Common situations: Custom plugins trying to open the completion popup by hand; replaying serialized actions that lost their attachments.

Related errors


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