{"record":{"id":"7e7f5f9657231ada","repo":"sxyazi/yazi","slug":"invalid-opt-in-displacedoform","errorCode":null,"errorMessage":"Invalid 'opt' in DisplaceDoForm","messagePattern":"Invalid 'opt' in DisplaceDoForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/mgr/displace_do.rs","lineNumber":15,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_core::mgr::DisplaceOpt;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug)]\npub struct DisplaceDoForm {\n\tpub opt: DisplaceOpt,\n}\n\nimpl TryFrom<ActionCow> for DisplaceDoForm {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(mut a: ActionCow) -> Result<Self, Self::Error> {\n\t\tOk(Self { opt: a.take_any(\"opt\").ok_or_else(|| anyhow!(\"Invalid 'opt' in DisplaceDoForm\"))? })\n\t}\n}\n\nimpl FromLua for DisplaceDoForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for DisplaceDoForm {\n\tfn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err(\"unsupported\".into_lua_err()) }\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-parser/src/mgr/displace_do.rs#L1-L26","documentation":"DisplaceDoForm carries the options for the internal mgr 'displace-do' action. Its TryFrom<ActionCow> implementation requires an 'opt' entry; when a.take_any(\"opt\") yields None the error \"Invalid 'opt' in DisplaceDoForm\" is thrown. The *_do actions are internal follow-ups triggered by confirmation forms, so the missing payload indicates a malformed internal dispatch.","triggerScenarios":"Dispatching mgr.displace-do without the typed Opt payload, or with an 'opt' whose stored type does not match DisplaceOpt so take_any fails.","commonSituations":"Custom code re-emitting the displace confirmation action manually; interrupted/miswired internal flow after a yazi upgrade changed how displace-do options are packaged.","solutions":["Attach the DisplaceOpt payload under 'opt' when constructing the displace-do action.","Dispatch the action through mgr's normal confirm path instead of hand-building ActionCow.","Check the yazi version's mgr/displace_do.rs for the exact Opt struct and field names.","Rebuild/update any patched or third-party plugin that emits this action."],"exampleFix":"// before\nlet a = ActionCow::from(\"mgr.displace-do\");\nlet form = DisplaceDoForm::try_from(a)?; // Invalid 'opt' in DisplaceDoForm\n// after\nlet a = ActionCow::from((\"mgr.displace-do\", DisplaceOpt::default()));\nlet form = DisplaceDoForm::try_from(a)?;","handlingStrategy":"validation","validationCode":"if !action.has(\"opt\") {\n    anyhow::bail!(\"mgr.displace-do requires DisplaceOpt under 'opt'\");\n}\nlet form = DisplaceDoForm::try_from(action)?;","typeGuard":"fn has_opt(a: &ActionCow) -> bool { a.has(\"opt\") }","tryCatchPattern":"let form = DisplaceDoForm::try_from(action)\n    .with_context(|| format!(\"displace-do malformed: {e:#}\"))?;","preventionTips":["Trigger displace via the user-facing 'displace' action and let mgr create displace-do itself.","Do not cache or re-dispatch internal *_do actions manually.","Pin plugin code to the yazi version whose Opt structs it targets."],"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"}