scylla icon indicating copy to clipboard operation
scylla copied to clipboard

Can't access API

Open CharlesCCC opened this issue 5 years ago • 1 comments

Describe the bug Can't access the following API

http://localhost:8899/api/v1/proxies

To Reproduce Steps to reproduce the behavior:

  1. install scylla through pip
  2. run scylla
  3. go to the API URL http://localhost:8899/api/v1/proxies
  4. Internal server error with the following error log
[2019-02-28 14:15:27 -0500] [38860] [ERROR] Traceback (most recent call last):
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\sanic\app.py", line 603, in handle_request
    response = await response
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\scylla\web\server.py", line 107, in api_v1_proxies
    'total_page': math.ceil(count / limit),
  File "c:\sandbox\scylla\venv-pipinstall\lib\site-packages\sanic\response.py", line 194, in json
    return HTTPResponse(dumps(body, **kwargs), headers=headers,
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\cocai1\AppData\Local\Programs\Python\Python36\lib\json\encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'datetime' is not JSON serializable

Expected behavior No error with actual stats

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version latest version

Additional context python 3.6.8 scylla 1.1.5

CharlesCCC avatar Feb 28 '19 19:02 CharlesCCC

It seems like the issue is at the \scylla\venv-pipinstall\Lib\site-packages\sanic\response.py file.

change the line to the following temp fixed the issue but the date will not showing correctly:

    return HTTPResponse(dumps(body, **kwargs, default=str), headers=headers,
                        status=status, content_type=content_type)

or need use json_dumps here https://github.com/imWildCat/scylla/blob/master/scylla/web/server.py#L102

CharlesCCC avatar Feb 28 '19 19:02 CharlesCCC