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

Unable to get file with json content #281

Closed
Michkov opened this issue Mar 2, 2018 · 2 comments
Closed

Unable to get file with json content #281

Michkov opened this issue Mar 2, 2018 · 2 comments
Milestone

Comments

@Michkov
Copy link

Michkov commented Mar 2, 2018

How to reproduce:

  1. create container, create file with json content eg. '{ }'
  2. try to get the file
from pylxd import Client
client = Client()
test = client.containers.get('test')
print(test.files.get('/test.json'))
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pylxd/client.py", line 88, in _assert_response
    if data['type'] != 'sync':
KeyError: 'type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 4, in <module>
    print(nginx.files.get('/etc/helthcheck'))
  File "/usr/lib/python3/dist-packages/pylxd/models/container.py", line 90, in get
    params={'path': filepath})
  File "/usr/lib/python3/dist-packages/pylxd/client.py", line 106, in get
    self._assert_response(response, stream=kwargs.get('stream', False))
  File "/usr/lib/python3/dist-packages/pylxd/client.py", line 92, in _assert_response
    raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: <exception str() failed>
@ajkavanagh ajkavanagh added the bug label Mar 2, 2018
@ajkavanagh
Copy link
Contributor

Okay, having had a look at the code, it's because the .files.get(...) implementation re-uses the API .get(...) method which checks if it's JSON and then assumes it must be protocol message and makes assumptions about what must be in the JSON. Hence the failure. I'll try to get this fixed soon.

@ajkavanagh ajkavanagh added this to the 2.2.7 milestone Mar 9, 2018
@ajkavanagh
Copy link
Contributor

See #290 for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants