{"record":{"id":"367b6ce3237ff7fe","repo":"sxyazi/yazi","slug":"invalid-lock-in-updatepeekedform","errorCode":null,"errorMessage":"Invalid 'lock' in UpdatePeekedForm","messagePattern":"Invalid 'lock' in UpdatePeekedForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/mgr/update_peeked.rs","lineNumber":18,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_binding::Scope;\nuse yazi_core::tab::PreviewLock;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug)]\npub struct UpdatePeekedForm {\n\tpub lock:  PreviewLock,\n\tpub scope: Scope,\n}\n\nimpl TryFrom<ActionCow> for UpdatePeekedForm {\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 UpdatePeekedForm\"))?,\n\t\t\tscope: a.take_any(\"scope\").unwrap_or_default(),\n\t\t})\n\t}\n}\n\nimpl FromLua for UpdatePeekedForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for UpdatePeekedForm {\n\tfn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err(\"unsupported\".into_lua_err()) }\n}\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-parser/src/mgr/update_peeked.rs#L1-L31","documentation":"UpdatePeekedForm delivers the result of a peek job back to the manager: it requires a 'lock' entry (the peek identity/token) and an optional 'scope'. The 'lock' is mandatory — a.take_any(\"lock\") returning None raises \"Invalid 'lock' in UpdatePeekedForm\". Without the lock the manager cannot correlate the update with the pending peek, so the message is rejected.","triggerScenarios":"Dispatching mgr.update-peeked without a 'lock' payload, or with a lock value of a type that cannot be taken as the expected PeekLock/target type.","commonSituations":"Plugin or third-party code faking a peek-update message; a yazi version change altering the lock representation so old emitters attach the wrong type; dropping fields when cloning/forwarding the action.","solutions":["Attach the original peek lock (obtained when initiating peek/peek jobs) under key 'lock'.","Ensure the lock type matches the current UpdatePeekedForm definition in your yazi version.","Emit peek updates via yazi's internal job completion path rather than constructing the action manually.","Optionally also set 'scope'; it defaults via unwrap_or_default, but the lock itself has no default."],"exampleFix":"// before\nlet a = ActionCow::from(\"mgr.update-peeked\"); // no lock\n// after\nlet a = ActionCow::from((\"mgr.update-peeked\", (lock, scope)));\n// 'lock' must be the PeekLock captured when the peek started","handlingStrategy":"validation","validationCode":"if !action.has(\"lock\") {\n    anyhow::bail!(\"update-peeked requires the peek 'lock'\");\n}\nlet form = UpdatePeekedForm::try_from(action)?;","typeGuard":"fn has_lock(a: &ActionCow) -> bool { a.has(\"lock\") }","tryCatchPattern":"let form = UpdatePeekedForm::try_from(action)\n    .context(\"peek update missing lock; drop stale update\")?; // safe to ignore","preventionTips":["Keep the peek lock from when the peek was started and always attach it to the update.","Only emit update-peeked from the peek job completion path.","Remember 'scope' is optional but 'lock' is not.","Discard (rather than forward) peek updates when the original lock is unavailable."],"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"}