SwissDataScienceCenter / renku-data-services

Services that handle reading and writing data from a database
Apache License 2.0
3 stars 2 forks source link

make data-service less chatty with `Preferences not found for user.` messages. #245

Closed Panaetius closed 3 months ago

Panaetius commented 3 months ago

Data Service (especially on startup) creates quite a few of these errors, but seems to be running fine:

[2024-06-06 07:33:58 +0000] [44] [ERROR] An unknown or unhandled exception occurred
Traceback (most recent call last):
  File "handle_request", line 102, in handle_request
    try:

  File "/app/env/lib/python3.12/site-packages/renku_data_services/base_api/auth.py", line 39, in decorated_function
    response = await f(request, user, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/user_preferences/blueprints.py", line 30, in _get
    user_preferences = await self.user_preferences_repo.get_user_preferences(user=user)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/user_preferences/db.py", line 47, in get_user_preferences
    raise errors.MissingResourceError(message="Preferences not found for user.")
renku_data_services.errors.errors.MissingResourceError: MissingResourceError: Preferences not found for user.

We should figure out what is actually calling this on a fresh deployment, and if we can fix this (can we just create default user preferences if there are none?)

leafty commented 3 months ago

This is most likely the result of the Cypress e2e tests creating a new user and loading the UI (which loads user preferences).

We should suppress expected errors anyway and just log the HTTP status, e.g.

A lot of these pollute the schemathesis logs as well, when the important logs e.g. 500 are buried.

leafty commented 3 months ago

Reference: https://sanic.dev/en/guide/best-practices/exceptions.html#using-sanic-exceptions