drewkerrigan/nagios-http-json

Bug if array element is 0

vanso-hubsi opened this issue · 3 comments

Hi!
First of all, thank you for that plugin!

I just wanted to start using it, when I stumbled across a possible bug:
I wanted to collect metrics of an integer value in an array and then found that if that value equals "0" the whole json is returned as metrics value.

I think the bug is in the get function:

        if temp_data:
            data = temp_data
        else:
            data = self.data

Since the value (in my case Integer 0) is passed to the get function as "temp_data" by getSubArrayElement, that check of temp_data returns "false".
I assumed that codeline is supposed to check if temp_data is empty and changed it to

        if temp_data != '':
            data = temp_data
        else:
            data = self.data

which seems to have fixed it.

Hi, thanks for the feedback. Can you give me an example of your data? I want to recreate the bug in a unittest.

Was fixed in #66

Thank you for the fix. 👍
And I'm sorry, seems I missed your request for a data sample. Only saw it now when you closed this issue 😉 .