sxyazi/yazi · error

Invalid 'opt' in OpenDoForm

Error message

Invalid 'opt' in OpenDoForm

What it means

OpenDoForm is the form for the internal mgr 'open-do' action (the confirmed phase of opening files). TryFrom<ActionCow> requires an 'opt' payload; absence or a type mismatch makes a.take_any("opt") return None and the error "Invalid 'opt' in OpenDoForm" is raised. This signals the open-do action was constructed without its typed OpenOpt options.

Solutions

  1. Provide the OpenOpt payload under key 'opt' when creating the open-do action.
  2. Prefer emitting the user-facing 'open' action and let yazi generate open-do internally.
  3. Match the Opt struct in yazi-parser/src/mgr/open_do.rs for your installed version.
  4. Update plugins/config emitters that construct this action by hand.

Example fix

// before
let a = ActionCow::from("mgr.open-do");
let form = OpenDoForm::try_from(a)?; // Invalid 'opt' in OpenDoForm
// after
let a = ActionCow::from(("mgr.open-do", OpenOpt::default()));
let form = OpenDoForm::try_from(a)?;
Defensive patterns

Strategy: validation

Validate before calling

if !action.has("opt") {
    anyhow::bail!("mgr.open-do requires OpenOpt under 'opt'");
}
let form = OpenDoForm::try_from(action)?;

Type guard

fn has_opt(a: &ActionCow) -> bool { a.has("opt") }

Try / catch

let form = OpenDoForm::try_from(action)
    .context("open-do needs 'opt'; emit 'open' instead")?;

Prevention

When it happens

Trigger: Building an mgr.open-do ActionCow with no 'opt' field, or with an 'opt' value that cannot be taken as the expected OpenOpt type.

Common situations: Custom keybindings/plugins emitting open-do directly; old plugin code after a yazi refactor of the open action payload; forwarding the action through a channel that only carries the action name.

Related errors


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

Appendix: source

Thrown at yazi-parser/src/mgr/open_do.rs:19

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

#[derive(Clone, Debug, Default)]
pub struct OpenDoForm {
	pub opt: OpenDoOpt,
}

impl From<OpenDoOpt> for OpenDoForm {
	fn from(opt: OpenDoOpt) -> Self { Self { opt } }
}

impl TryFrom<ActionCow> for OpenDoForm {
	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 OpenDoForm"))? })
	}
}

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

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

View on GitHub (pinned to 5f901b886b)