{"record":{"id":"bc4f00c633dd1e64","repo":"sxyazi/yazi","slug":"invalid-token-in-showform","errorCode":null,"errorMessage":"Invalid 'token' in ShowForm","messagePattern":"Invalid 'token' in ShowForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/confirm/show.rs","lineNumber":21,"sourceCode":"use yazi_config::popup::ConfirmCfg;\nuse yazi_shared::{CompletionToken, event::ActionCow};\n\n#[derive(Debug)]\npub struct ShowForm {\n\tpub cfg:   ConfirmCfg,\n\tpub token: CompletionToken,\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\tlet Some(cfg) = a.take_any(\"cfg\") else {\n\t\t\tbail!(\"Invalid 'cfg' in ShowForm\");\n\t\t};\n\n\t\tlet Some(token) = a.take_any(\"token\") else {\n\t\t\tbail!(\"Invalid 'token' in ShowForm\");\n\t\t};\n\n\t\tOk(Self { cfg, token })\n\t}\n}\n\nimpl From<Box<Self>> for ShowForm {\n\tfn from(value: Box<Self>) -> Self { *value }\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":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-parser/src/confirm/show.rs#L3-L39","documentation":"`ShowForm::try_from` also requires a `\"token\"` key, extracted after cfg. The token correlates the shown dialog with the pending confirmation request; without it the form cannot be built and this error is raised.","triggerScenarios":"Emitting `confirm:show` with cfg present but no `\"token\"` entry, or the token stored under a different key/type so `take_any(\"token\")` yields None.","commonSituations":"Plugin code that forwards cfg but forgets the request token; manually constructing the action in scripts/IPC; key renamed in a yazi update.","solutions":["Include the `\"token\"` value (the confirmation request token) in the action payload.","Ensure the token was obtained from the confirm plugin's request step and passed through unchanged.","Check for key spelling/type mismatches when building the ActionCow."],"exampleFix":"-- before (Lua)\nya.manager_emit(\"plugin\", { \"confirm\", args = { \"show\", cfg = my_cfg } })\n-- after\nya.manager_emit(\"plugin\", { \"confirm\", args = { \"show\", cfg = my_cfg, token = tok } })","handlingStrategy":"validation","validationCode":"assert!(action.get(\"cfg\").is_some() && action.get(\"token\").is_some(),\n        \"confirm:show requires both 'cfg' and 'token'\");","typeGuard":"fn is_valid_show_action(a: &Action) -> bool {\n    a.get(\"cfg\").is_some() && a.get(\"token\").is_some()\n}","tryCatchPattern":"match ShowForm::try_from(action) {\n    Ok(form) => show(form),\n    Err(e) if e.to_string().contains(\"Invalid 'token'\") => {\n        eprintln!(\"confirm:show missing 'token': {e}\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always forward the request token from the confirm request step unchanged.","Build confirm:show actions through a single helper that requires (cfg, token).","Check payload key spellings when constructing actions manually in Lua/IPC."],"tags":["parser","confirm-dialog","action-payload","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}