{"record":{"id":"4c092c108e80d6dc","repo":"sxyazi/yazi","slug":"invalid-opt-in-opendoform","errorCode":null,"errorMessage":"Invalid 'opt' in OpenDoForm","messagePattern":"Invalid 'opt' in OpenDoForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/mgr/open_do.rs","lineNumber":19,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_core::mgr::OpenDoOpt;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug, Default)]\npub struct OpenDoForm {\n\tpub opt: OpenDoOpt,\n}\n\nimpl From<OpenDoOpt> for OpenDoForm {\n\tfn from(opt: OpenDoOpt) -> Self { Self { opt } }\n}\n\nimpl TryFrom<ActionCow> for OpenDoForm {\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 OpenDoForm\"))? })\n\t}\n}\n\nimpl FromLua for OpenDoForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for OpenDoForm {\n\tfn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err(\"unsupported\".into_lua_err()) }\n}\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-parser/src/mgr/open_do.rs#L1-L30","documentation":"OpenDoForm is the form for the internal mgr 'open-do' action (the confirmed phase of opening files). TryFrom<ActionCow> requires an 'opt' payload; absence or a type mismatch makes a.take_any(\"opt\") return None and the error \"Invalid 'opt' in OpenDoForm\" is raised. This signals the open-do action was constructed without its typed OpenOpt options.","triggerScenarios":"Building an mgr.open-do ActionCow with no 'opt' field, or with an 'opt' value that cannot be taken as the expected OpenOpt type.","commonSituations":"Custom keybindings/plugins emitting open-do directly; old plugin code after a yazi refactor of the open action payload; forwarding the action through a channel that only carries the action name.","solutions":["Provide the OpenOpt payload under key 'opt' when creating the open-do action.","Prefer emitting the user-facing 'open' action and let yazi generate open-do internally.","Match the Opt struct in yazi-parser/src/mgr/open_do.rs for your installed version.","Update plugins/config emitters that construct this action by hand."],"exampleFix":"// before\nlet a = ActionCow::from(\"mgr.open-do\");\nlet form = OpenDoForm::try_from(a)?; // Invalid 'opt' in OpenDoForm\n// after\nlet a = ActionCow::from((\"mgr.open-do\", OpenOpt::default()));\nlet form = OpenDoForm::try_from(a)?;","handlingStrategy":"validation","validationCode":"if !action.has(\"opt\") {\n    anyhow::bail!(\"mgr.open-do requires OpenOpt under 'opt'\");\n}\nlet form = OpenDoForm::try_from(action)?;","typeGuard":"fn has_opt(a: &ActionCow) -> bool { a.has(\"opt\") }","tryCatchPattern":"let form = OpenDoForm::try_from(action)\n    .context(\"open-do needs 'opt'; emit 'open' instead\")?;","preventionTips":["Emit 'mgr.open' (the user action) rather than 'open-do'; the confirmed form is generated internally.","When testing internal actions, always attach the full Opt payload.","Track yazi changelogs for open-action payload changes."],"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"}