Skip to content

Internal Server Error when trying to settle #1443

@vxnxnt

Description

@vxnxnt

I run into an "Internal Server Error" each time immediately after pressing the "Register settlement" button. I'm running the project locally in docker and I confirmed this error on a separate instance I quickly spun up and imported from my original instance. I doubled checked that my default currency is set as well.
I would really appreciate the help!

Here are my docker logs:

[2026-04-25 09:31:47 +0000] [1] [INFO] Starting gunicorn 25.1.0
[2026-04-25 09:31:47 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2026-04-25 09:31:47 +0000] [1] [INFO] Using worker: sync
[2026-04-25 09:31:47 +0000] [1] [INFO] Control socket listening at /gunicorn.ctl
[2026-04-25 09:31:47 +0000] [4] [INFO] Booting worker with pid: 4
/src/ihatemoney/run.py:89: UserWarning: Running a server without changing the SECRET_KEY can lead to user impersonation. Please update your configuration file.
  warnings.warn(
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> b9a10d5d63ce, Initial migration
INFO  [alembic.runtime.migration] Running upgrade b9a10d5d63ce -> 26d6a218c329, Add Person.weight column
INFO  [alembic.runtime.migration] Running upgrade 26d6a218c329 -> f629c8ef4ab0, Initialize all members weights to 1
INFO  [alembic.runtime.migration] Running upgrade f629c8ef4ab0 -> b78f8a8bdb16, hash project passwords
INFO  [alembic.runtime.migration] Running upgrade b78f8a8bdb16 -> afbf27e6ef20, add bill.import_date field
INFO  [alembic.runtime.migration] Running upgrade afbf27e6ef20 -> a67119aa3ee5, Migrate negative weights
INFO  [alembic.runtime.migration] Running upgrade a67119aa3ee5 -> 6c6fb2b7f229, empty message
INFO  [alembic.runtime.migration] Running upgrade 6c6fb2b7f229 -> 2dcb0c0048dc, autologger
INFO  [alembic.runtime.migration] Running upgrade 2dcb0c0048dc -> cb038f79982e, sqlite_autoincrement
INFO  [alembic.runtime.migration] Running upgrade cb038f79982e -> 927ed575acbd, Add currencies
INFO  [alembic.runtime.migration] Running upgrade 927ed575acbd -> 7a9b38559992, new bill type attribute added
INFO  [alembic.runtime.migration] Running wrapper 7a9b38559992 -> 06884b17c50f, fix password hash length
/src/ihatemoney/currency_convertor.py:30: UserWarning: Call to https://api.exchangerate.host/latest?base=USD failed: KeyError: 'rates'
  warnings.warn(
ERROR [ihatemoney.run] Exception on /test/settle [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 1511, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 919, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask_restful/__init__.py", line 298, in error_router
    return original_handler(e)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 917, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/flask/app.py", line 902, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/src/ihatemoney/web.py", line 885, in add_settlement_bill
    settlement = Bill(
                 ^^^^^
  File "<string>", line 4, in __init__
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state.py", line 596, in _initialize_instance
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 121, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/orm/state.py", line 594, in _initialize_instance
    manager.original_init(*mixed[1:], **kwargs)
  File "/src/ihatemoney/models.py", line 747, in __init__
    self.converted_amount = self.currency_helper.exchange_currency(
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/src/ihatemoney/currency_convertor.py", line 224, in exchange_currency
    source_rate = rates[source_currency]
                  ~~~~~^^^^^^^^^^^^^^^^^
KeyError: ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions