aaif-goose/goose · error

Unsupported format: {}

Error message

Unsupported format: {}

What it means

The --format value of `goose session export` is a free String validated by this match, not by clap's value parser, so any string outside the exact set json|yaml|markdown reaches this arm. Matching is case-sensitive with no aliases (md, yml are rejected).

Source

Thrown at crates/goose-cli/src/commands/session.rs:254

        Err(e) => {
            return Err(anyhow::anyhow!(
                "Session '{}' not found or failed to read: {}",
                session_id,
                e
            ));
        }
    };

    let output = match format.as_str() {
        "json" => serde_json::to_string_pretty(&session)?,
        "yaml" => serde_yaml::to_string(&session)?,
        "markdown" => {
            let conversation = session
                .conversation
                .ok_or_else(|| anyhow::anyhow!("Session has no messages"))?;
            export_session_to_markdown(conversation.user_visible_messages(), &session.name)
        }
        _ => return Err(anyhow::anyhow!("Unsupported format: {}", format)),
    };

    #[cfg(feature = "nostr")]
    if nostr {
        if format != "json" {
            return Err(anyhow::anyhow!(
                "Nostr session sharing only supports --format json"
            ));
        }
        if output_path.is_some() {
            return Err(anyhow::anyhow!(
                "Nostr session sharing cannot be combined with --output"
            ));
        }

        let relays = nostr_share::resolve_relays(relays, Config::global());
        let share = nostr_share::publish_session_json(&output, relays).await?;
        println!("Session published to Nostr relays:");

View on GitHub (pinned to 3810898a74)

Solutions

  1. Use exactly one of: json, yaml, markdown (lowercase)
  2. If combining with --nostr, use json (see the separate nostr format error)
  3. Parameterize scripts through a validated allowlist of the three values

Example fix

# before
goose session export <id> --format md
# after
goose session export <id> --format markdown
Defensive patterns

Strategy: validation

Validate before calling

assert!(is_supported_export_format(&format), "format must be json, yaml, or markdown");
handle_session_export(id, out, format, nostr, relays).await?;

Type guard

fn is_supported_export_format(f: &str) -> bool {
    matches!(f, "json" | "yaml" | "markdown")
}

Prevention

When it happens

Trigger: `--format xml`, `--format md`, `--format JSON` (uppercase), or a typo like `--format jsson`.

Common situations: muscle memory from other tools (md/yml abbreviations); copy-pasting format names from outdated docs; shell scripts parameterizing the format with an unvalidated variable.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/5cc77b10b69433a6. Report an issue: GitHub.