Skip to content

Fix filter=count output to avoid empty objects#208

Open
dheeraj12347 wants to merge 1 commit intoapache:mainfrom
dheeraj12347:fix-filter-empty-rows
Open

Fix filter=count output to avoid empty objects#208
dheeraj12347 wants to merge 1 commit intoapache:mainfrom
dheeraj12347:fix-filter-empty-rows

Conversation

@dheeraj12347
Copy link
Copy Markdown

@dheeraj12347 dheeraj12347 commented Mar 26, 2026

Fixes #197 where using filter=count resulted in empty objects being printed in list responses.

Problem

When filter=count is applied, CloudMonkey still iterates over list items and prints empty {} entries, even when the filtered field does not exist in those list objects.

Fix

  • Skip empty rows after filtering.
  • Omit list fields when no valid entries remain after applying the filter.
  • Preserve only relevant top-level fields (for example, "count").

Result

Before, a command such as:

(localcloud) > list usagerecords startdate=2025-10-07 enddate=2025-10-10 type=6 usageid=2c218702-abff-46e8-bc8a-3e12fffa2188 filter=count

could return:

{
  "count": 319,
  "usagerecord": [
    {},
    {},
    ...
    {}
  ]
}

Now the output correctly returns only the top-level count field:

{
  "count": 319
}

instead of including empty objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter on parameter listing empty objects when filtered parameter doesn't exists

1 participant