spiral-project / ihatemoney

A simple shared budget manager web application
https://ihatemoney.org
Other
1.2k stars 269 forks source link

KeyError "rates" when running `make serve` on latest master #735

Closed almet closed 3 years ago

almet commented 3 years ago

After a fresh install, it seems that the currency convertor isn't up to date with the returned JSON from their API.

See the traceback.

Traceback (most recent call last):
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/alexis/ihatemoney/ihatemoney/web.py", line 256, in home
    project_form = ProjectForm()
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/wtforms/form.py", line 212, in __call__
    return type.__call__(cls, *args, **kwargs)
  File "/home/alexis/ihatemoney/ihatemoney/forms.py", line 116, in __init__
    for currency_name in self.currency_helper.get_currencies()
  File "/home/alexis/ihatemoney/ihatemoney/currency_convertor.py", line 31, in get_currencies
    for rate in self.get_rates()
  File "/home/alexis/ihatemoney/.venv/lib/python3.7/site-packages/cachetools/decorators.py", line 22, in wrapper
    v = func(*args, **kwargs)
  File "/home/alexis/ihatemoney/ihatemoney/currency_convertor.py", line 24, in get_rates
    rates = requests.get(self.api_url).json()["rates"]
KeyError: 'rates'
almet commented 3 years ago

It seems to be because I don't have an API key for their service.

{'success': False, 'error': {'code': 101, 'type': 'missing_access_key', 'info': 'You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]'}}
almet commented 3 years ago

Seems related to https://github.com/exchangeratesapi/exchangeratesapi/issues/117