You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/03/02 22:18:00 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #5600: Adding check for safer conversion between types

rawlinp commented on a change in pull request #5600:
URL: https://github.com/apache/trafficcontrol/pull/5600#discussion_r585950615



##########
File path: traffic_ops/traffic_ops_golang/cachesstats/cachesstats.go
##########
@@ -146,11 +146,19 @@ func addStats(cacheData []CacheData, stats tc.Stats) []CacheData {
 		}
 		bandwidth, ok := stat.Stats[tc.StatNameBandwidth]
 		if ok && len(bandwidth) > 0 {
-			cache.KBPS = bandwidth[0].Val.(uint64)
+			cache.KBPS, ok = bandwidth[0].Val.(uint64)

Review comment:
       So when I was looking at this, it seemed like TM was serving this data as strings. If that's the case, we would be hitting this warning case every time. Maybe we need to actually convert the string to a uint64 using `strconv` instead of casting it?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org