trafficcontrol icon indicating copy to clipboard operation
trafficcontrol copied to clipboard

buildHttpStatusChartData Cannot read property 'forEach' of null

Open mitchell852 opened this issue 3 years ago • 3 comments

This Bug Report affects these Traffic Control components:

  • Traffic Portal

Current behavior:

The ds charts view in TP has an error if the api returns no values. Example:

https://tp.domain.tld/#!/delivery-services/42/charts?type=HTTP <-- this view calls GET /api/4.0/deliveryservice_stats

If the api endpoint returns no values (series.values = null), it will throw this error:

Cannot read property 'forEach' of null

Expected behavior:

Handle the empty value without throwing an error.

Steps to reproduce:

See current behavior

mitchell852 avatar Oct 04 '21 16:10 mitchell852

IMO a set of no results in the series is best represented by the empty set ([] in JSON, which is actually an Array not a Set) instead of null. But also that's partly coming from InfluxDB's enthusiastic use of null, so idk how much we want to do about that. Though it would also solve the issue by just not needing to handle that case.

In any case, I think this is probably a three-line fix wherever it gets implemented, so I think this is probably a good first issue.

ocket8888 avatar Oct 04 '21 17:10 ocket8888

IMO a set of no results in the series is best represented by the empty set ([] in JSON, which is actually an Array not a Set) instead of null. But also that's partly coming from InfluxDB's enthusiastic use of null, so idk how much we want to do about that. Though it would also solve the issue by just not needing to handle that case.

In any case, I think this is probably a three-line fix wherever it gets implemented, so I think this is probably a good first issue.

yeah, should be a simple null check

mitchell852 avatar Oct 08 '21 17:10 mitchell852

Can I pick this up? What files would I need to look at?

deepto98 avatar Jun 19 '22 15:06 deepto98

@mitchell852 I created a PR, please take a look!

ntheanh201 avatar Oct 24 '23 05:10 ntheanh201