{"record":{"id":"c2b63dc59d55205b","repo":"aaif-goose/goose","slug":"failed-to-serialize-arguments","errorCode":null,"errorMessage":"Failed to serialize arguments: {}","messagePattern":"Failed to serialize arguments: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/session/mod.rs","lineNumber":1997,"sourceCode":"    }\n\n    /// Handle prompt command execution\n    async fn handle_prompt_command(&mut self, opts: input::PromptCommandOptions) -> Result<()> {\n        // name is required\n        if opts.name.is_empty() {\n            output::render_error(\"Prompt name argument is required\");\n            return Ok(());\n        }\n\n        if opts.info {\n            match self.get_prompt_info(&opts.name).await? {\n                Some(info) => output::render_prompt_info(&info),\n                None => output::render_error(&format!(\"Prompt '{}' not found\", opts.name)),\n            }\n        } else {\n            // Convert the arguments HashMap to a Value\n            let arguments = serde_json::to_value(opts.arguments)\n                .map_err(|e| anyhow::anyhow!(\"Failed to serialize arguments: {}\", e))?;\n\n            match self.get_prompt(&opts.name, arguments).await {\n                Ok(messages) => {\n                    let start_len = self.messages.len();\n                    let mut valid = true;\n                    let num_messages = messages.len();\n                    for (i, prompt_message) in messages.into_iter().enumerate() {\n                        let msg = Message::from(prompt_message);\n                        // ensure we get a User - Assistant - User type pattern\n                        let expected_role = if i % 2 == 0 {\n                            rmcp::model::Role::User\n                        } else {\n                            rmcp::model::Role::Assistant\n                        };\n\n                        if msg.role != expected_role {\n                            output::render_error(&format!(\n                                \"Expected {:?} message at position {}, but found {:?}\",","sourceCodeStart":1979,"sourceCodeEnd":2015,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/session/mod.rs#L1979-L2015","documentation":"Before invoking an extension prompt, goose converts the arguments map to a serde_json::Value. For the string-keyed, string-valued map used here, to_value is effectively infallible, so this error is a defensive wrap around serde_json::to_value's Result rather than a realistic failure mode; the inner error {e} would name the offending value.","triggerScenarios":"Running a prompt with arguments (get_prompt path) where to_value returns Err — only conceivable after the arguments type changes to something not JSON-representable.","commonSituations":"Practically unreproducible with current types; would surface after an API change to the argument map's key or value types.","solutions":["Read the inner error {e} to identify which value failed to serialize","Keep prompt arguments as string-to-string pairs as documented"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn args_are_serializable(args: &HashMap<String, String>) -> bool {\n    serde_json::to_value(args).is_ok()\n}","typeGuard":null,"tryCatchPattern":"let arguments = match serde_json::to_value(opts.arguments) {\n    Ok(v) => v,\n    Err(e) => {\n        eprintln!(\"prompt arguments not JSON-serializable: {}\", e);\n        return Ok(());\n    }\n};","preventionTips":["Keep prompt arguments as string-to-string pairs","Validate complex argument values with serde_json::to_value before the call"],"tags":["serialization","serde-json","prompts","cli"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}