sxyazi/yazi · error

Invalid 'op' in UpdateFilesForm

Error message

Invalid 'op' in UpdateFilesForm

What it means

UpdateFilesForm carries a file-update operation payload and the `op` field (the update operation data) is mandatory. The TryFrom<ActionCow> implementation takes `op` from the action and bails when it is missing, so an update_files action without operation data cannot be constructed.

Source

Thrown at yazi-parser/src/mgr/update_files.rs:17

use anyhow::bail;
use mlua::{FromLua, IntoLua, Lua, Table, Value};
use yazi_fs::FilesOp;
use yazi_shared::{event::ActionCow, id::Id};

#[derive(Debug)]
pub struct UpdateFilesForm {
	pub op:   FilesOp,
	pub tabs: Vec<Id>,
}

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

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

		Ok(Self { op, tabs: vec![] })
	}
}

impl From<FilesOp> for UpdateFilesForm {
	fn from(op: FilesOp) -> Self { Self { op, tabs: vec![] } }
}

impl FromLua for UpdateFilesForm {
	fn from_lua(value: Value, lua: &Lua) -> mlua::Result<Self> {
		let t = Table::from_lua(value, lua)?;

		Ok(Self { op: t.raw_get("op")?, tabs: t.raw_get("tabs")? })
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Always include the `op` payload key (the update-op data) when emitting update_files
  2. Re-read the changed file entries and rebuild the op payload rather than forwarding an empty table
  3. Log/inspect the action payload before emit to confirm `op` is present

Example fix

// before
ya.emit('update_files', { tabs = { tab.id } })
// after
ya.emit('update_files', { op = op, tabs = { tab.id } })
Defensive patterns

Strategy: validation

Validate before calling

assert(op ~= nil, "update_files requires an 'op' payload")
ya.emit('update_files', { op = op, tabs = tabs })

Try / catch

-- Rust
match UpdateFilesForm::try_from(action) {
  Ok(form) => handle(form),
  Err(e) => tracing::warn!("update_files skipped: {e}"),
}

Prevention

When it happens

Trigger: Emitting a `update_files` action without an `op` payload key, e.g. `ya.emit('update_files', { tabs = ... })` with no `op`, or `Manager:update_files({})`.

Common situations: Plugin code forwarding file-update events after dropping or renaming the payload fields; hand-built IPC/remote-control messages missing the op entry.

Related errors


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