aaif-goose/goose · error

Nostr session sharing only supports --format json

Error message

Nostr session sharing only supports --format json

What it means

Nostr sharing publishes the session as a JSON payload to relays, so the --nostr flag only accepts --format json. This check runs after the output was already rendered, rejecting yaml/markdown combinations before any network call.

Source

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

        }
    };

    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:");
        for relay in &share.relays {
            println!("- {}", relay);
        }
        println!("\nShare link:");
        println!("{}", share.deeplink);
        return Ok(());

View on GitHub (pinned to 3810898a74)

Solutions

  1. Drop the format flag or set --format json when using --nostr
  2. For a yaml/markdown file, remove --nostr and use --output

Example fix

# before
goose session export <id> --nostr --format markdown
# after
goose session export <id> --nostr              # json is the default payload
goose session export <id> --format markdown    # no nostr, prints locally
Defensive patterns

Strategy: validation

Validate before calling

if nostr && format != "json" {
    anyhow::bail!("--nostr requires --format json"); // fail before running the command
}
handle_session_export(id, out, format, nostr, relays).await?;

Type guard

fn nostr_format_valid(nostr: bool, format: &str) -> bool {
    !nostr || format == "json"
}

Prevention

When it happens

Trigger: `goose session export <id> --nostr --format yaml` or `--nostr --format markdown`.

Common situations: Reusing a yaml/markdown export command line and just appending --nostr; scripts that always pass --format plus --nostr.

Related errors


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