You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bs...@apache.org on 2026/09/03 10:13:18 UTC

(cloudstack-cloudmonkey) branch main updated: Fix filter=count output to avoid empty objects (#197) (#208)

This is an automated email from the ASF dual-hosted git repository.

borisstoyanov pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack-cloudmonkey.git


The following commit(s) were added to refs/heads/main by this push:
     new 8da415a  Fix filter=count output to avoid empty objects (#197) (#208)
8da415a is described below

commit 8da415af33b0ef01e6170e93d8ea240c39273d87
Author: Dheeraj Bansal <dh...@gmail.com>
AuthorDate: Thu Sep 3 15:43:13 2026 +0530

    Fix filter=count output to avoid empty objects (#197) (#208)
---
 cmd/output.go | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/cmd/output.go b/cmd/output.go
index 79f3900..434b644 100644
--- a/cmd/output.go
+++ b/cmd/output.go
@@ -278,8 +278,19 @@ func filterResponse(response map[string]interface{}, filter []string, excludeFil
 					}
 				}
 
+				// Skip completely empty rows after filtering
+				if len(filteredRow) == 0 {
+					continue
+				}
+
 				filteredRows = append(filteredRows, filteredRow)
 			}
+
+			// If no non-empty rows remain for this key, omit the key entirely
+			if len(filteredRows) == 0 {
+				continue
+			}
+
 			if originalKind == reflect.Map && len(filteredRows) > 0 {
 				filteredResponse[key] = filteredRows[0]
 			} else {