aaif-goose/goose · error
Failed to encode recipe: {}
Error message
Failed to encode recipe: {} What it means
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.
Source
Thrown at crates/goose-cli/src/commands/recipe.rs:189
) -> Result<(String, goose::recipe::Recipe)> {
let recipe_file = load_recipe_file(recipe_name)?;
// Load the recipe file first to validate it
let recipe = validate_recipe_template_from_file(&recipe_file)?;
match recipe_deeplink::encode(&recipe) {
Ok(encoded) => {
let mut full_url = format!("goose://recipe?config={}", encoded);
// Append parameters as additional query parameters
for (key, value) in params {
// URL-encode the parameter keys and values
let encoded_key = urlencoding::encode(&key);
let encoded_value = urlencoding::encode(&value);
full_url.push_str(&format!("&{}={}", encoded_key, encoded_value));
}
Ok((full_url, recipe))
}
Err(err) => Err(anyhow::anyhow!("Failed to encode recipe: {}", err)),
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::fs;
use tempfile::TempDir;
fn create_test_recipe_file(dir: &TempDir, filename: &str, content: &str) -> String {
let file_path = dir.path().join(filename);
fs::write(&file_path, content).expect("Failed to write test recipe file");
file_path.to_string_lossy().into_owned()
}
const VALID_RECIPE_CONTENT: &str = r#"
title: "Test Recipe with Valid JSON Schema"
description: "A test recipe with valid JSON schema"View on GitHub (pinned to 3810898a74)
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
Defensive patterns
Strategy: validation
Validate before calling
// Rust: validate before encoding use goose::recipe::validate_recipe::validate_recipe_template_from_file; validate_recipe_template_from_file(&recipe_file)?; let (url, _) = /* generate_deeplink(...) */; // only encode after validation passes
Prevention
- Keep recipe files plain (strings, lists, maps)
- Validate recipes in CI before sharing deeplinks
- Regenerate deeplinks after edits instead of hand-modifying URLs
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to open recipe: {}
- Invalid parameter format: '{}'. Expected format: key=value
- Invalid deeplink or recipe format
- {} recipe file is invalid: {}
- Failed to list recipes: {}
AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16).
Data as JSON: /api/errors/ad08b734e17db188.
Report an issue: GitHub.