sxyazi/yazi · error

Invalid 'cfg' in ShowForm

Error message

Invalid 'cfg' in ShowForm

What it means

`ShowForm::try_from(ActionCow)` for the confirm dialog's `show` action extracts `"cfg"` with `a.take_any("cfg")`; a missing `"cfg"` key aborts construction with this error. The cfg carries the dialog's content/configuration, so without it the dialog cannot be shown.

Source

Thrown at yazi-parser/src/confirm/show.rs:17

use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use yazi_config::popup::ConfirmCfg;
use yazi_shared::{CompletionToken, event::ActionCow};

#[derive(Debug)]
pub struct ShowForm {
	pub cfg:   ConfirmCfg,
	pub token: CompletionToken,
}

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

	fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
		let Some(cfg) = a.take_any("cfg") else {
			bail!("Invalid 'cfg' in ShowForm");
		};

		let Some(token) = a.take_any("token") else {
			bail!("Invalid 'token' in ShowForm");
		};

		Ok(Self { cfg, token })
	}
}

impl From<Box<Self>> for ShowForm {
	fn from(value: Box<Self>) -> Self { *value }
}

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

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Pass the confirm dialog configuration as `"cfg"` in the action payload.
  2. Fix key typos (`cfg`, not `config` or `opts`).
  3. Verify against the current confirm plugin API for how cfg is serialized into the action.

Example fix

-- before (Lua)
ya.manager_emit("plugin", { "confirm", args = { "show", token = tok } })
-- after: include cfg
ya.manager_emit("plugin", { "confirm", args = { "show", cfg = my_cfg, token = tok } })
Defensive patterns

Strategy: validation

Validate before calling

assert!(action.get("cfg").is_some(), "confirm:show requires 'cfg'");

Type guard

fn is_valid_show_action(a: &Action) -> bool {
    a.get("cfg").is_some()
}

Try / catch

match ShowForm::try_from(action) {
    Ok(form) => show(form),
    Err(e) if e.to_string().contains("Invalid 'cfg'") => {
        eprintln!("confirm:show missing 'cfg': {e}")
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Emitting a `confirm:show` ActionCow without a `"cfg"` entry, or under a wrong key/type so `take_any("cfg")` returns None.

Common situations: Lua plugins calling the confirm plugin with missing arguments; typos like `config` instead of `cfg`; version drift where the payload key changed between yazi releases.

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/1e5ea2c62b7e9a9b. Report an issue: GitHub.