{"record":{"id":"7fe88ab8781c58da","repo":"sxyazi/yazi","slug":"invalid-opt-in-spawnform","errorCode":null,"errorMessage":"Invalid 'opt' in SpawnForm","messagePattern":"Invalid 'opt' in SpawnForm","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-parser/src/tasks/spawn.rs","lineNumber":15,"sourceCode":"use anyhow::anyhow;\nuse mlua::{ExternalError, FromLua, IntoLua, Lua, Value};\nuse yazi_core::tasks::TaskOpt;\nuse yazi_shared::event::ActionCow;\n\n#[derive(Clone, Debug)]\npub struct SpawnForm {\n\tpub opt: TaskOpt,\n}\n\nimpl TryFrom<ActionCow> for SpawnForm {\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 SpawnForm\"))? })\n\t}\n}\n\nimpl FromLua for SpawnForm {\n\tfn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err(\"unsupported\".into_lua_err()) }\n}\n\nimpl IntoLua for SpawnForm {\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/tasks/spawn.rs#L1-L26","documentation":"SpawnForm holds the options for spawning a task via the tasks subsystem. TryFrom<ActionCow> requires an 'opt' entry; if a.take_any(\"opt\") returns None (missing key or wrong type) the error \"Invalid 'opt' in SpawnForm\" is raised. It fails fast when a spawn action reaches the parser without its typed SpawnOpt payload.","triggerScenarios":"Constructing a tasks.spawn ActionCow without 'opt', or with an 'opt' value not matching the expected SpawnOpt type so take_any fails.","commonSituations":"Custom task spawners in config/plugins emitting spawn manually; renamed or reshaped options after a yazi upgrade; the action forwarded with only its name and no payload.","solutions":["Provide the SpawnOpt payload under key 'opt' when building the spawn action.","Verify the SpawnOpt struct/fields in yazi-parser/src/tasks/spawn.rs for your yazi version.","Use the high-level task spawn API (e.g. TASKS.spawn(...)) instead of raw ActionCow construction.","Update plugin/config emitters to match the current payload schema."],"exampleFix":"// before\nlet a = ActionCow::from(\"tasks.spawn\");\nlet form = SpawnForm::try_from(a)?; // Invalid 'opt' in SpawnForm\n// after\nlet a = ActionCow::from((\"tasks.spawn\", SpawnOpt::default()));\nlet form = SpawnForm::try_from(a)?;","handlingStrategy":"validation","validationCode":"if !action.has(\"opt\") {\n    anyhow::bail!(\"tasks.spawn requires SpawnOpt under 'opt'\");\n}\nlet form = SpawnForm::try_from(action)?;","typeGuard":"fn has_opt(a: &ActionCow) -> bool { a.has(\"opt\") }","tryCatchPattern":"let form = SpawnForm::try_from(action)\n    .with_context(|| \"spawn action malformed: missing 'opt'\")?;","preventionTips":["Spawn tasks via the high-level TASKS.spawn API, not raw ActionCow.","Always pair the spawn action with its SpawnOpt payload.","Re-verify payload shape after yazi upgrades in custom spawners."],"tags":["rust","action-parsing","missing-field","tasks","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"}