sxyazi/yazi · error

Invalid 'cfg' in ShowForm

Error message

Invalid 'cfg' in ShowForm

What it means

ShowForm (the `pick.show`/show action for the picker) requires a `cfg` field containing the configuration to display. TryFrom<ActionCow> bails when `cfg` is absent from the action payload, since showing without a config payload is meaningless.

Source

Thrown at yazi-parser/src/pick/show.rs:18

use anyhow::bail;
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
use tokio::sync::mpsc;
use yazi_config::popup::PickCfg;
use yazi_shared::event::ActionCow;

#[derive(Debug)]
pub struct ShowForm {
	pub cfg: PickCfg,
	pub tx:  mpsc::UnboundedSender<Option<usize>>,
}

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(tx) = a.take_any("tx") else {
			bail!("Invalid 'tx' in ShowForm");
		};

		Ok(Self { cfg, tx })
	}
}

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 5f901b886b)

Solutions

  1. Include the `cfg` payload key with the config value: `show({ cfg = cfg, tx = tx })`
  2. Verify the source that built the action actually serializes cfg (not omitted as nil)
  3. Check for typos such as `config` instead of `cfg`

Example fix

// before
ya.emit('show', { tx = tx })
// after
ya.emit('show', { cfg = cfg, tx = tx })
Defensive patterns

Strategy: validation

Validate before calling

assert(cfg ~= nil, "show requires 'cfg'")
ya.emit('show', { cfg = cfg, tx = tx })

Type guard

local function is_valid_show(opts)
  return type(opts) == "table" and opts.cfg ~= nil
end

Prevention

When it happens

Trigger: Emitting a `show` action without the `cfg` payload key, e.g. `ya.emit('show', { tx = ... })` or `Pick:show({})`.

Common situations: Plugin authors constructing show actions manually and forgetting the config table; serializing/deserializing across the IPC boundary where cfg was dropped.

Related errors


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