Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changeset/fix-formatter-empty-arrays.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---\n"@googleworkspace/cli": patch\n---\n\nfix(formatter): correctly handle empty list responses from API
8 changes: 3 additions & 5 deletions src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ fn extract_items(value: &Value) -> Option<(&str, &Vec<Value>)> {
continue;
}
if let Value::Array(arr) = val {
if !arr.is_empty() {
return Some((key, arr));
}
return Some((key, arr));
}
}
}
Expand Down Expand Up @@ -640,9 +638,9 @@ mod tests {
#[test]
fn test_format_table_empty_array() {
let val = json!({"files": []});
// No items to extract, falls back to single-object table
// Items are extracted correctly, but since the array is empty, we get (empty)
let output = format_value(&val, &OutputFormat::Table);
assert!(output.contains("files"));
assert_eq!(output, "(empty)\n");
}

#[test]
Expand Down
Loading