{"record":{"id":"ad08b734e17db188","repo":"aaif-goose/goose","slug":"failed-to-encode-recipe","errorCode":null,"errorMessage":"Failed to encode recipe: {}","messagePattern":"Failed to encode recipe: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/commands/recipe.rs","lineNumber":189,"sourceCode":") -> Result<(String, goose::recipe::Recipe)> {\n    let recipe_file = load_recipe_file(recipe_name)?;\n    // Load the recipe file first to validate it\n    let recipe = validate_recipe_template_from_file(&recipe_file)?;\n    match recipe_deeplink::encode(&recipe) {\n        Ok(encoded) => {\n            let mut full_url = format!(\"goose://recipe?config={}\", encoded);\n\n            // Append parameters as additional query parameters\n            for (key, value) in params {\n                // URL-encode the parameter keys and values\n                let encoded_key = urlencoding::encode(&key);\n                let encoded_value = urlencoding::encode(&value);\n                full_url.push_str(&format!(\"&{}={}\", encoded_key, encoded_value));\n            }\n\n            Ok((full_url, recipe))\n        }\n        Err(err) => Err(anyhow::anyhow!(\"Failed to encode recipe: {}\", err)),\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n    use std::fs;\n    use tempfile::TempDir;\n\n    fn create_test_recipe_file(dir: &TempDir, filename: &str, content: &str) -> String {\n        let file_path = dir.path().join(filename);\n        fs::write(&file_path, content).expect(\"Failed to write test recipe file\");\n        file_path.to_string_lossy().into_owned()\n    }\n\n    const VALID_RECIPE_CONTENT: &str = r#\"\ntitle: \"Test Recipe with Valid JSON Schema\"\ndescription: \"A test recipe with valid JSON schema\"","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/recipe.rs#L171-L207","documentation":"Generating a recipe deeplink requires serializing the loaded recipe through recipe_deeplink::encode into the URL payload. If that encode step fails, the raw error is wrapped with this message at the match's Err arm; the deeplink is never produced.","triggerScenarios":"A recipe that loads from disk but cannot be encoded: fields that fail serialization into the deeplink payload, non-string data where strings are required, or payload constraints enforced by the encoder.","commonSituations":"Hand-crafted recipes with exotic YAML types (dates, anchors, tags) that do not round-trip; recipes moved between goose versions whose payload format changed; extremely large recipes exceeding URL constraints.","solutions":["Read the embedded error text for the encoding failure reason","Run `goose recipe validate` on the same file and fix everything it reports first","Simplify the recipe to plain string/list/map fields and regenerate","Update goose in case the encoder's accepted schema changed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: validate before encoding\nuse goose::recipe::validate_recipe::validate_recipe_template_from_file;\nvalidate_recipe_template_from_file(&recipe_file)?;\nlet (url, _) = /* generate_deeplink(...) */; // only encode after validation passes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep recipe files plain (strings, lists, maps)","Validate recipes in CI before sharing deeplinks","Regenerate deeplinks after edits instead of hand-modifying URLs"],"tags":["recipe","deeplink","serialization","cli"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}