{"record":{"id":"a765a680bef2e88f","repo":"sxyazi/yazi","slug":"invalid-opt-in-showform","errorCode":null,"errorMessage":"Invalid 'opt' in ShowForm","messagePattern":"Invalid 'opt' in ShowForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/cmp/show.rs","lineNumber":19,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_core::cmp::CmpOpt;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug)]\npub struct ShowForm {\n\tpub opt: CmpOpt,\n}\n\nimpl From<CmpOpt> for ShowForm {\n\tfn from(opt: CmpOpt) -> Self { Self { opt } }\n}\n\nimpl TryFrom<ActionCow> for ShowForm {\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 ShowForm\"))? })\n\t}\n}\n\nimpl FromLua for ShowForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for ShowForm {\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/cmp/show.rs#L1-L30","documentation":"ShowForm (the form payload for the cmp plugin's 'show' action) is built via TryFrom<ActionCow>, which requires the action to carry a payload under the key 'opt' that deserializes to the expected option type. When a.take_any(\"opt\") returns None — the field is absent or of a type that cannot be taken as the target type — the anyhow! error \"Invalid 'opt' in ShowForm\" is raised. This guards internal action dispatch: the 'show' action must be dispatched programmatically with its typed options attached, not constructed ad-hoc.","triggerScenarios":"Dispatching an ActionCow for cmp.show without an 'opt' field (a.take_any(\"opt\") = None), or with an 'opt' value whose type does not match the struct's Opt field so take_any fails to downcast/convert it.","commonSituations":"Plugin or keymap code constructing the cmp show action manually and forgetting the payload; a version change renamed or restructured the options payload so older emitters no longer attach 'opt'; sending the action through a path that strips extra fields.","solutions":["Attach the typed options payload under the key 'opt' when constructing the show action, e.g. via the action's builder/with() API with the cmp show Opt struct.","Ensure the value stored under 'opt' is exactly the expected Opt type for this ShowForm version; re-check the yazi version's cmp show options struct.","If emitting from Lua, use the supported emit path so Rust-side options are serialized into the action rather than building a bare ActionCow.","Update any custom plugin/patch code that created the action to match the current yazi-parser API (field names/shape may have changed)."],"exampleFix":"// before\nlet a = ActionCow::from(\"cmp.show\");\nlet form = ShowForm::try_from(a)?; // Invalid 'opt' in ShowForm\n// after\nlet a = ActionCow::from((\"cmp.show\", ShowOpt { /* fields */ }));\nlet form = ShowForm::try_from(a)?;","handlingStrategy":"validation","validationCode":"// Rust: check before TryFrom\nif !action.has(\"opt\") {\n    anyhow::bail!(\"cmp.show requires an 'opt' payload\");\n}\nlet form = ShowForm::try_from(action)?;","typeGuard":"fn has_opt(a: &ActionCow) -> bool { a.has(\"opt\") }","tryCatchPattern":"match ShowForm::try_from(action) {\n    Ok(form) => handle(form),\n    Err(e) => tracing::error!(\"cmp.show action malformed: {e:#}\"),\n}","preventionTips":["Always construct actions via yazi's typed emit/builder helpers instead of bare ActionCow.","Never send actions that carry only a name when the form requires a payload.","Re-check action payload construction after every yazi upgrade.","Log the full action keys when a TryFrom fails to spot missing fields fast."],"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"}