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

500 Internal Server Error /api/3/network/interface_name #1401

Closed
VinhLoiIT opened this issue Jan 23, 2019 · 4 comments
Closed

500 Internal Server Error /api/3/network/interface_name #1401

VinhLoiIT opened this issue Jan 23, 2019 · 4 comments
Assignees
Milestone

Comments

@VinhLoiIT
Copy link

Description

Hi there,
I recently found the bug in RESTful-API
I have got the latest version of glances from python3-pip installer
When I start the webserver via: glances -w -p 8282
And access the RESTful-API: localhost:8282/api/3/network/interface_name (the one I just copied from https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API), I got the 500 Internal Server Error
Read the Trace back log:
Traceback (most recent call last): File "/home/vinhloiit/glances/env/bin/bottle.py", line 862, in _handle return route.call(**args) File "/home/vinhloiit/glances/env/bin/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 619, in _enable_cors return fn(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 499, in _api_item return self._api_itemvalue(plugin, item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 473, in _api_itemvalue ret = self.stats.get_plugin(plugin).get_stats_item(item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 393, in get_stats_item return self._json_dumps({item: map(itemgetter(item), self.stats)}) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 148, in _json_dumps return json.dumps(d) File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.6/json/encoder.py", line 180, in default o.__class__.__name__) TypeError: Object of type 'map' is not JSON serializable

Well, the error from map in _json_dumps in glances_plugin.py, I found on https://stackoverflow.com/questions/33989430/map-object-is-not-json-serializable and see that this map is not the same as python 2

Versions

  • Glances & psutil (glances -V):
    Glances v3.1.0 with psutil v5.4.8

  • Operating System (lsb_release -a):
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 18.04.1 LTS
    Release: 18.04
    Codename: bionic

Logs

https://pastebin.com/1hF1fSNy

@nicolargo
Copy link
Owner

Hi @VinhLoiIT Many thanks for the issue report.

I just publish a patch on the DEVELOP branch. Can you test it ?

@VinhLoiIT
Copy link
Author

Hi @VinhLoiIT Many thanks for the issue report.

I just publish a patch on the DEVELOP branch. Can you test it ?

Yeah this issues is solved. Should I append a short code in unittest-restful.py?

@nicolargo
Copy link
Owner

I will...

Thanks !

nicolargo added a commit that referenced this issue Jan 24, 2019
@nicolargo
Copy link
Owner

Done in latest commit.

nicolargo added a commit that referenced this issue Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants