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]Error when add flavor on fog05 from /flavor/add API #92

Closed
miquelpuigmena opened this issue May 29, 2019 · 2 comments
Closed

[BUG]Error when add flavor on fog05 from /flavor/add API #92

miquelpuigmena opened this issue May 29, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@miquelpuigmena
Copy link

Describe the bug
Fail to deploy new instance from OSMr5 with fog05 vim plugin.
When instantiating ns-instance on fog05-vim an errors triggers when POST /flavor/add. Returns 500.

Error
May 29 10:39:19 fog05 fos_rest[19385]: Traceback (most recent call last):
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2309, in call
May 29 10:39:19 fog05 fos_rest[19385]: return self.wsgi_app(environ, start_response)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2295, in wsgi_app
May 29 10:39:19 fog05 fos_rest[19385]: response = self.handle_exception(e)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1741, in handle_exception
May 29 10:39:19 fog05 fos_rest[19385]: reraise(exc_type, exc_value, tb)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 35, in reraise
May 29 10:39:19 fog05 fos_rest[19385]: raise value
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2292, in wsgi_app
May 29 10:39:19 fog05 fos_rest[19385]: response = self.full_dispatch_request()
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1815, in full_dispatch_request
May 29 10:39:19 fog05 fos_rest[19385]: rv = self.handle_user_exception(e)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1718, in handle_user_exception
May 29 10:39:19 fog05 fos_rest[19385]: reraise(exc_type, exc_value, tb)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 35, in reraise
May 29 10:39:19 fog05 fos_rest[19385]: raise value
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1813, in full_dispatch_request
May 29 10:39:19 fog05 fos_rest[19385]: rv = self.dispatch_request()
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1799, in dispatch_request
May 29 10:39:19 fog05 fos_rest[19385]: return self.view_functionsrule.endpoint
May 29 10:39:19 fog05 fos_rest[19385]: File "/etc/fos/rest/service.py", line 274, in flavor_add
May 29 10:39:19 fog05 fos_rest[19385]: descriptor = json.loads(request.data)
May 29 10:39:19 fog05 fos_rest[19385]: File "/usr/lib/python3.5/json/init.py", line 312, in loads
May 29 10:39:19 fog05 fos_rest[19385]: s.class.name))
May 29 10:39:19 fog05 fos_rest[19385]: TypeError: the JSON object must be str, not 'bytes'

Desktop:

  • Ubuntu 16.04
  • OpenStack VM
@miquelpuigmena miquelpuigmena added the bug Something isn't working label May 29, 2019
@gabrik
Copy link
Contributor

gabrik commented May 31, 2019

Thanks @miquelpuigmena for this bug report.
I guess that when the code of the REST Proxy was written request.data was returning str but now it returns bytes.

The fix should be easy as:

data = response.data
if isinstance(bytes,data):
   data = data.decode()
descriptor = json.loads(data) 

Will fix this in next pull request

gabrik added a commit to atolab/fog05 that referenced this issue Jun 12, 2019
gabrik added a commit that referenced this issue Jun 12, 2019
Verify the type of the `request.data` before converting it to dict using `json.loads`
@gabrik
Copy link
Contributor

gabrik commented Jun 12, 2019

Fixed by #98

@gabrik gabrik closed this as completed Jun 12, 2019
gabrik added a commit that referenced this issue Nov 26, 2020
Verify the type of the `request.data` before converting it to dict using `json.loads`
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