{"record":{"id":"ba86a53e4b31e44d","repo":"sxyazi/yazi","slug":"invalid-lock-in-updatespottedform","errorCode":null,"errorMessage":"Invalid 'lock' in UpdateSpottedForm","messagePattern":"Invalid 'lock' in UpdateSpottedForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/mgr/update_spotted.rs","lineNumber":16,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_core::spot::SpotLock;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug)]\npub struct UpdateSpottedForm {\n\tpub lock: SpotLock,\n}\n\nimpl TryFrom<ActionCow> for UpdateSpottedForm {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {\n\t\tOk(Self {\n\t\t\tlock: a.take_any(\"lock\").ok_or_else(|| anyhow!(\"Invalid 'lock' in UpdateSpottedForm\"))?,\n\t\t})\n\t}\n}\n\nimpl FromLua for UpdateSpottedForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for UpdateSpottedForm {\n\tfn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err(\"unsupported\".into_lua_err()) }\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-parser/src/mgr/update_spotted.rs#L1-L28","documentation":"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.","triggerScenarios":"Constructing mgr.update-spotted without a 'lock' entry, or attaching a lock value whose type differs from what UpdateSpottedForm expects (take_any fails).","commonSituations":"Manually emitting spot updates from custom code; version drift where the lock struct changed; actions stripped of payload when re-sent across components.","solutions":["Include the spot lock captured when the spot was initiated under key 'lock'.","Verify the lock type against yazi-parser/src/mgr/update_spotted.rs in your version.","Use the built-in spot job completion flow instead of hand-assembling the action.","Update any patched emitters to the current payload format."],"exampleFix":"// before\nlet a = ActionCow::from(\"mgr.update-spotted\"); // missing lock\n// after\nlet a = ActionCow::from((\"mgr.update-spotted\", lock));","handlingStrategy":"validation","validationCode":"if !action.has(\"lock\") {\n    anyhow::bail!(\"update-spotted requires the spot 'lock'\");\n}\nlet form = UpdateSpottedForm::try_from(action)?;","typeGuard":"fn has_lock(a: &ActionCow) -> bool { a.has(\"lock\") }","tryCatchPattern":"let form = UpdateSpottedForm::try_from(action)\n    .context(\"spot update missing lock; ignoring\")?; // stale results are safe to drop","preventionTips":["Thread the spot lock through the whole spot job and attach it to the result.","Never synthesize spot updates in plugin code.","After upgrading yazi, re-verify the lock type used in any custom emitter."],"tags":["rust","action-parsing","missing-field","yazi"],"backgroundTag":"missing-required-action-field","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}