aaif-goose/goose · error

Nostr session sharing cannot be combined with --output

Error message

Nostr session sharing cannot be combined with --output

What it means

--nostr publishes the rendered session to Nostr relays and prints a share link; --output writes the same bytes to a local file. The two destinations are mutually exclusive by design and this check rejects the combination before publishing.

Source

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

        "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(());
    }
    #[cfg(not(feature = "nostr"))]
    if nostr {
        return Err(anyhow::anyhow!("goose was not built with nostr support"));
    }

View on GitHub (pinned to 3810898a74)

Solutions

  1. Remove --output when sharing via --nostr (the deeplink is printed to stdout)
  2. Run two commands if you need both: one plain export with --output, one --nostr export

Example fix

# before
goose session export <id> --nostr --output out.json
# after
goose session export <id> --nostr                          # prints share link
goose session export <id> --format json --output out.json   # local copy
Defensive patterns

Strategy: validation

Validate before calling

if nostr && output_path.is_some() {
    anyhow::bail!("--nostr cannot be combined with --output");
}
handle_session_export(id, output_path, format, nostr, relays).await?;

Type guard

fn nostr_output_valid(nostr: bool, output: Option<&Path>) -> bool {
    !(nostr && output.is_some())
}

Prevention

When it happens

Trigger: `goose session export <id> --nostr --output session.json`.

Common situations: Wrapping export in a script that always saves a local copy, then adding --nostr without removing --output.

Related errors


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