-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(cli): channels get exits non-zero on unknown channel instead of printing null #5704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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::Value> = 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" | ||
| ))); | ||
|
Comment on lines
+233
to
+236
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This changes the documented error-path behavior, but AGENTS.md reference: AGENTS.md:L202-L202 Useful? React with 👍 / 👎. |
||
| }; | ||
| 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(()) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
/queryreturns a successful HTTP response whose body is not a JSON array—for example, a malformed or truncated relay response—line 232 converts the parse failure into an empty vector, so this new branch reportsnot_foundwith exit code 1 even though the channel's existence was never established. Propagate the deserialization failure as an unexpected error before testing whether the decoded array is empty.AGENTS.md reference: AGENTS.md:L195-L197
Useful? React with 👍 / 👎.