{"record":{"id":"e267d7b2090e0265","repo":"aaif-goose/goose","slug":"nostr-session-sharing-only-supports-format-json","errorCode":null,"errorMessage":"Nostr session sharing only supports --format json","messagePattern":"Nostr session sharing only supports --format json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/commands/session.rs","lineNumber":260,"sourceCode":"        }\n    };\n\n    let output = match format.as_str() {\n        \"json\" => serde_json::to_string_pretty(&session)?,\n        \"yaml\" => serde_yaml::to_string(&session)?,\n        \"markdown\" => {\n            let conversation = session\n                .conversation\n                .ok_or_else(|| anyhow::anyhow!(\"Session has no messages\"))?;\n            export_session_to_markdown(conversation.user_visible_messages(), &session.name)\n        }\n        _ => return Err(anyhow::anyhow!(\"Unsupported format: {}\", format)),\n    };\n\n    #[cfg(feature = \"nostr\")]\n    if nostr {\n        if format != \"json\" {\n            return Err(anyhow::anyhow!(\n                \"Nostr session sharing only supports --format json\"\n            ));\n        }\n        if output_path.is_some() {\n            return Err(anyhow::anyhow!(\n                \"Nostr session sharing cannot be combined with --output\"\n            ));\n        }\n\n        let relays = nostr_share::resolve_relays(relays, Config::global());\n        let share = nostr_share::publish_session_json(&output, relays).await?;\n        println!(\"Session published to Nostr relays:\");\n        for relay in &share.relays {\n            println!(\"- {}\", relay);\n        }\n        println!(\"\\nShare link:\");\n        println!(\"{}\", share.deeplink);\n        return Ok(());","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/session.rs#L242-L278","documentation":"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.","triggerScenarios":"`goose session export <id> --nostr --format yaml` or `--nostr --format markdown`.","commonSituations":"Reusing a yaml/markdown export command line and just appending --nostr; scripts that always pass --format plus --nostr.","solutions":["Drop the format flag or set --format json when using --nostr","For a yaml/markdown file, remove --nostr and use --output"],"exampleFix":"# before\ngoose session export <id> --nostr --format markdown\n# after\ngoose session export <id> --nostr              # json is the default payload\ngoose session export <id> --format markdown    # no nostr, prints locally","handlingStrategy":"validation","validationCode":"if nostr && format != \"json\" {\n    anyhow::bail!(\"--nostr requires --format json\"); // fail before running the command\n}\nhandle_session_export(id, out, format, nostr, relays).await?;","typeGuard":"fn nostr_format_valid(nostr: bool, format: &str) -> bool {\n    !nostr || format == \"json\"\n}","tryCatchPattern":null,"preventionTips":["Treat --nostr as json-only in every wrapper; validate flag combinations up front","When scripting, set format='json' explicitly wherever --nostr is used"],"tags":["session","nostr","argument-validation","export"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}