sxyazi/yazi · error

Invalid 'lock' in UpdateSpottedForm

Error message

Invalid 'lock' in UpdateSpottedForm

What it means

UpdateSpottedForm reports spot results back to the manager and requires a 'lock' payload identifying the spot request. If a.take_any("lock") returns None — key absent or wrong type — the error "Invalid 'lock' in UpdateSpottedForm" is raised. The lock is required to match the update against the outstanding spot so stale results can be discarded.

Solutions

  1. Include the spot lock captured when the spot was initiated under key 'lock'.
  2. Verify the lock type against yazi-parser/src/mgr/update_spotted.rs in your version.
  3. Use the built-in spot job completion flow instead of hand-assembling the action.
  4. Update any patched emitters to the current payload format.

Example fix

// before
let a = ActionCow::from("mgr.update-spotted"); // missing lock
// after
let a = ActionCow::from(("mgr.update-spotted", lock));
Defensive patterns

Strategy: validation

Validate before calling

if !action.has("lock") {
    anyhow::bail!("update-spotted requires the spot 'lock'");
}
let form = UpdateSpottedForm::try_from(action)?;

Type guard

fn has_lock(a: &ActionCow) -> bool { a.has("lock") }

Try / catch

let form = UpdateSpottedForm::try_from(action)
    .context("spot update missing lock; ignoring")?; // stale results are safe to drop

Prevention

When it happens

Trigger: Constructing mgr.update-spotted without a 'lock' entry, or attaching a lock value whose type differs from what UpdateSpottedForm expects (take_any fails).

Common situations: Manually emitting spot updates from custom code; version drift where the lock struct changed; actions stripped of payload when re-sent across components.

Related errors


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

Appendix: source

Thrown at yazi-parser/src/mgr/update_spotted.rs:16

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

#[derive(Clone, Debug)]
pub struct UpdateSpottedForm {
	pub lock: SpotLock,
}

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

	fn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {
		Ok(Self {
			lock: a.take_any("lock").ok_or_else(|| anyhow!("Invalid 'lock' in UpdateSpottedForm"))?,
		})
	}
}

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

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

View on GitHub (pinned to 5f901b886b)