You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using the http input plugin to parse out metrics out of one of our services but found Telegraf failing on an empty array (on service startup, our endpoint responds with an empty array until it receives a request).
I took a look and found the isarray function doesn't consider this edge-case. The condition for an array is ia > -1 && ia < ib, where ia is the index of [, and ib is the index of {. If { never occurs though (e.g. in an empty array), then ia is actually greater than ib. Changing the condition to ia > -1 && (ib == -1 || ia < ib) makes it work.
The errors aren't that big of a deal because Telegraf will just retry, but it'd be nice to not have any spurious errors in the logs. Lemme know if you guys would like a PR. 😄
The text was updated successfully, but these errors were encountered:
I was using the
http
input plugin to parse out metrics out of one of our services but found Telegraf failing on an empty array (on service startup, our endpoint responds with an empty array until it receives a request).I took a look and found the
isarray
function doesn't consider this edge-case. The condition for an array isia > -1 && ia < ib
, whereia
is the index of[
, andib
is the index of{
. If{
never occurs though (e.g. in an empty array), thenia
is actually greater thanib
. Changing the condition toia > -1 && (ib == -1 || ia < ib)
makes it work.The errors aren't that big of a deal because Telegraf will just retry, but it'd be nice to not have any spurious errors in the logs. Lemme know if you guys would like a PR. 😄
The text was updated successfully, but these errors were encountered: