Skip to content

Empty array handling for ReportTemplate.html#1336

Open
rberghuis wants to merge 1 commit into
microsoft:mainfrom
rberghuis:MobileDeviceDiagram
Open

Empty array handling for ReportTemplate.html#1336
rberghuis wants to merge 1 commit into
microsoft:mainfrom
rberghuis:MobileDeviceDiagram

Conversation

@rberghuis

Copy link
Copy Markdown

The Mobile Devices diagram received data but did no validation before handing it to the library. Two things were missing:

1. It passed zero-value links
If a tenant has no mobile devices, all the mobile links have value 0. Those zeros were passed straight to d3-sankey, which tried to draw a chart with no meaningful data.

2. It had no guard for empty data.
When all links are zero, filtering them out leaves an empty dataset. d3-sankey then tried to compute new Array(max_depth + 1) where max_depth is undefined (no nodes to measure), which evaluates to new Array(NaN), an invalid operation that crashes the whole page.

The fix adds two lines of defence:

  1. Strip out any links with a value of zero or null before doing anything else.
  2. If nothing is left after stripping, show "No data available." instead of attempting to render the chart.

Copilot AI review requested due to automatic review settings June 22, 2026 12:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants