Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] 'pairs' on unexpected variable value #119

Open
labertasche42 opened this issue Jan 25, 2023 · 2 comments
Open

[bug] 'pairs' on unexpected variable value #119

labertasche42 opened this issue Jan 25, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@labertasche42
Copy link

I have too many devices and thus even in the normal openwrt 22 cli, ubus call network.device status throws a time out.
Entirely my problem, but through this time out

local network_status = ubus:call('network.device', 'status', {})
gets an unexpected assignment and by this
for name, interface in pairs(network_status) do
fails.
This in turn results in an empty report in this in a HTTP 400 from the openwisp server.

The solution could be to either check every variable, before pairs is used on it and omit this part in the report, if there should be an error, or to abort the whole script, if ubus:call has an error.

@nemesifier
Copy link
Member

@labertasche42 interesting! Does it always timeout or if you keep repeating it would work?

@labertasche42
Copy link
Author

labertasche42 commented Jan 26, 2023

Hey @nemesisdesign,

as every timeout is 30 seconds I just did test 6 calls, but yes, even after 6 calls it always times out. But this is a problem of the ubus command line tool and should probably a report somewhere else.

openwrt-openwisp-monitoring's Line 123 and Line 112's problem is missing input sanitization which subsequently led in my case to errors like #101 or #102
In my opinion it should be something like

if type(x) == "table" then 
for a, b in pairs(x) do
...
else
 [errorreport]

For my case, I changed L65 to local network_status = {} for now to get at least all the other informations. A filter in the ubus:call in L65 would have worked too, but I was too lazy to recode L124ff

@nemesifier nemesifier changed the title 'pairs' on unexpected variable value [bug] 'pairs' on unexpected variable value Aug 21, 2023
@nemesifier nemesifier added the bug Something isn't working label Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants