aristanetworks / aristanetworks/goeapi
Can't unmarshal -Infinity
- Dominant language
- Go
- Stars
- 60
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
When trying to unmarshall the output of `show interfaces transceiver dom thresholds`, you sometimes can come across a channel value with -Infinity. This causes the JSON decoder to fail with an error like this:
```interface-diagnostics: invalid character 'I' in numeric literal"```
The JSON object in question looks like this:
```
{
"interfaces": {
"Ethernet54/1": {
"updateTime": 1628733658.605624,
"displayName": "Ethernet54/1",
"parameters": {
"txPower": {
"channels": {
"1": -Infinity
},
"threshold": {},
"unit": "dBm"
},
"temperature": {
"channels": {
"-": 29.703125
},
"threshold": {
"highWarn": 70.0,
"lowWarn": 0.0,
"highAlarm": 75.0,
"lowAlarm": -5.0
},
"unit": "C"
},
"txBias": {
"channels": {
"1": 0.0
},
"threshold": {
"highWarn": 0.0,
"lowWarn": 0.0,
"highAlarm": 0.0,
"lowAlarm": 0.0
},
"unit": "mA"
},
"rxPower": {
"channels": {
"1": -30.0
},
"threshold": {},
"unit": "dBm"
},
"voltage": {
"channels": {
"-": 3.3201
},
"threshold": {
"highWarn": 3.45,
"lowWarn": 3.1500000000000004,
"highAlarm": 3.8000000000000003,
"lowAlarm": 2.8400000000000003
},
"unit": "V"
}
},
"vendorSn": "XXXXXX",
"mediaType": "40GBASE-SR4"
}
}
```
It seems that -Infinity isn't valid JSON, so it isn't supported by the JSON parser. So what is the way to handle this so you can at least skip over this value and still get the rest of the valid data back?
Contributor guide
Research direction
Start by reproducing issue #46 with the `show interfaces transceiver dom thresholds` response containing `-Infinity`, then trace the Go JSON decoding entry point used for eAPI output. Done means the response can be decoded without the invalid channel value causing failure, while the remaining valid data is still returned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100