HomePhabricator

Guard against empty result in `populate_groupings` when getting the counts for…

Description

Guard against empty result in populate_groupings when getting the counts for a column

If the dashboard is configured to have a column although that column
is never used on any item, then this resulted in a hard crash. [1]

Here we explicitly guard against an empty result and just skip it.

The cells attribute is then not populated with any data (not even zeroes),
but during formatting a zero value is assumed if no cell is found,
so a zero-column will be displayed.

Also add a unit test for populate_groupings confirming the behaviour.

(Interestingly there was a pyright [2] warning on that line,
flagging that data could potentially be None).

Bug: T338684

[1] Stack trace:

File "./property_statistics.py", line 386, in retrieve_data for grouping_item, value in data.items():
AttributeError: 'NoneType' object has no attribute 'items'

[2] https://github.com/microsoft/pyright