From 0f86ec53fbc5501a83346c2a0445404d5b8bb3a5 Mon Sep 17 00:00:00 2001 From: obbax Date: Wed, 12 Aug 2026 23:34:09 +0200 Subject: [PATCH] fix(cli): channels get exits non-zero on unknown channel instead of printing null MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `buzz channels get --channel ` for a channel that doesn't exist printed the literal string `null` to stdout and exited 0 — indistinguishable from success in automation/scripts that check exit codes rather than parsing output. Return CliError::NotFound (same convention as `buzz mem get`, `projects get`, etc.) so the CLI now prints an error to stderr and exits 1. Signed-off-by: obbax --- crates/buzz-cli/src/commands/channels.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/buzz-cli/src/commands/channels.rs b/crates/buzz-cli/src/commands/channels.rs index 5cc745d7b94..00448a9d4c4 100644 --- a/crates/buzz-cli/src/commands/channels.rs +++ b/crates/buzz-cli/src/commands/channels.rs @@ -230,14 +230,15 @@ pub async fn cmd_get_channel(client: &BuzzClient, channel_id: &str) -> Result<() }); let resp = client.query(&filter).await?; let events: Vec = serde_json::from_str(&resp).unwrap_or_default(); - if let Some(e) = events.first() { - let mut normalized = extract_channel_metadata(e); - normalized["pubkey"] = - serde_json::json!(e.get("pubkey").and_then(|v| v.as_str()).unwrap_or("")); - println!("{normalized}"); - } else { - println!("null"); - } + let Some(e) = events.first() else { + return Err(CliError::NotFound(format!( + "channel '{channel_id}' not found" + ))); + }; + let mut normalized = extract_channel_metadata(e); + normalized["pubkey"] = + serde_json::json!(e.get("pubkey").and_then(|v| v.as_str()).unwrap_or("")); + println!("{normalized}"); Ok(()) }