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

Creating a Kraken API connection with a Kraken user with no balances/transactions fails #943

Closed
isidorosp opened this issue Apr 27, 2020 · 0 comments · Fixed by #944
Closed
Assignees
Labels
backend bug Something isn't working
Milestone

Comments

@isidorosp
Copy link
Contributor

isidorosp commented Apr 27, 2020

Problem Definition

If the user has a Kraken account that is "empty" (no balances, trades, etc.) and they attempt to create a Kraken API connection with valid API keys, the following happens:

  • The backend returns a 500 error to the client
  • The user is unable to set up a Kraken connection from this point on as they get an error that Kraken is already registered (it appears as unregistered but providing credentials and clicking "setup" returns the "Exchange kraken is already registered" error).

This appears to happen because the API result from Kraken is malformed during the initial API connection from the backend, as it provides a response of {'error': []} which the backend doesn't know how to handle. As a result a 500 internal error occurs, no credentials are registered, but the exchange does appear to be registered (doing a manual GET call to the /exchanges endpoint will show this). Following this, the user must perform a manual DELETE call to the /exchanges endpoint to delete the erroneous kraken exchange before they can create a new connection via the client UI.

27/04/2020 17:06:16 W. Europe Daylight Time -- INFO:rotkehlchen.exchanges.exchange:Initialized kraken exchange
27/04/2020 17:06:16 W. Europe Daylight Time -- DEBUG:rotkehlchen.exchanges.kraken:Kraken API query method=Balance, data=None, call_counter=0
27/04/2020 17:06:16 W. Europe Daylight Time -- ERROR:rotkehlchen.api.server:Exception on /api/1/exchanges [PUT]
Traceback (most recent call last):
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\flask\app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\flask_restful\__init__.py", line 458, in wrapper
    resp = resource(*args, **kwargs)
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\flask\views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\flask_restful\__init__.py", line 573, in dispatch_request
    resp = meth(*args, **kwargs)
  File "C:\Users\Gebruiker\Envs\rotkehlchen\lib\site-packages\webargs\core.py", line 366, in wrapper
    return func(*args, **kwargs)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\api\v1\resources.py", line 215, in put
    return self.rest_api.setup_exchange(name, api_key, api_secret, passphrase)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\api\rest.py", line 109, in wrapper
    return f(wrappingobj, *args, **kwargs)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\api\rest.py", line 377, in setup_exchange
    result, message = self.rotkehlchen.setup_exchange(name, api_key, api_secret, passphrase)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\rotkehlchen.py", line 635, in setup_exchange
    passphrase=passphrase,
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\manager.py", line 78, in setup_exchange
    result, message = exchange.validate_api_key()
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\kraken.py", line 318, in validate_api_key
    valid, msg = self._validate_single_api_key_action('Balance')
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\kraken.py", line 341, in _validate_single_api_key_action
    self.api_query(method_str, req)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\kraken.py", line 419, in api_query
    result = query_method(method, req)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\kraken.py", line 471, in _query_private
    return _check_and_get_response(response, method)
  File "c:\users\gebruiker\source\repos\rotki\rotkehlchen\exchanges\kraken.py", line 246, in _check_and_get_response
    return result['result']
KeyError: 'result'

... (and later if i try to register it again I get this)

27/04/2020 17:06:33 W. Europe Daylight Time -- INFO:rotkehlchen.api.server.pywsgi:127.0.0.1 - - [2020-04-27 17:06:33] "OPTIONS /api/1/exchanges HTTP/1.1" 200 327 0.001009
27/04/2020 17:06:33 W. Europe Daylight Time -- DEBUG:rotkehlchen.api.rest:Request successful response={"result": null, "message": "Exchange kraken is already registered"}, status_code=409
@isidorosp isidorosp added bug Something isn't working backend labels Apr 27, 2020
@LefterisJP LefterisJP self-assigned this Apr 27, 2020
@LefterisJP LefterisJP added this to the v1.4.2 milestone Apr 27, 2020
@LefterisJP LefterisJP added this to To do in Next patch release via automation Apr 27, 2020
@LefterisJP LefterisJP moved this from To do to In progress in Next patch release Apr 27, 2020
LefterisJP added a commit to LefterisJP/rotkehlchen that referenced this issue Apr 28, 2020
Fixing main part of rotki#943, namely the 500 error thrown when Kraken
returned the unexpected 200 OK {"error": []} response without a
"result" key
Next patch release automation moved this from In progress to Done Apr 28, 2020
LefterisJP added a commit that referenced this issue Apr 28, 2020
Fixing main part of #943, namely the 500 error thrown when Kraken
returned the unexpected 200 OK {"error": []} response without a
"result" key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants