SwissDataScienceCenter / renku-data-services

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

HTTP 500 in connected services #539

Open leafty opened 6 hours ago

leafty commented 6 hours ago

To investigate:

Srv 0 2024-11-20 07:57:21 +0000 ERROR: Exception occurred while handling uri: 'https://dev.renku.ch/api/data/oauth2/connections/01HYZ9X2VZAY87988991JA2J48/installations?per_page=100'
Traceback (most recent call last):
  File "handle_request", line 102, in handle_request
    if TYPE_CHECKING:

  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/base_api/misc.py", line 93, in decorated_function
    return await validate(query=query)(f)(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/sanic_ext/extras/validation/decorator.py", line 75, in decorated_function
    retval = await retval
             ^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/base_api/pagination.py", line 90, in decorated_function
    items, db_count = await f(request, *args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/connected_services/blueprints.py", line 205, in _get_installations
    installations_list = await self.connected_services_repo.get_oauth2_app_installations(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/connected_services/db.py", line 346, in get_oauth2_app_installations
    response = await oauth2_client.get(request_url, params=params, headers=adapter.api_common_headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/httpx/_client.py", line 1814, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 86, in request
    await self.ensure_active_token(self.token)
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 113, in ensure_active_token
    await self.refresh_token(url, refresh_token=refresh_token)
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 149, in _refresh_token
    token = self.parse_response_token(resp)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/authlib/oauth2/client.py", line 355, in parse_response_token
    raise self.oauth_error_class(
authlib.integrations.base_client.errors.OAuthError: bad_refresh_token: The refresh token passed is incorrect or expired.
ERROR:sanic.error:Exception occurred while handling uri: 'https://dev.renku.ch/api/data/oauth2/connections/01HYZ9X2VZAY87988991JA2J48/installations?per_page=100'
Traceback (most recent call last):
  File "handle_request", line 102, in handle_request
    if TYPE_CHECKING:

  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/base_api/misc.py", line 93, in decorated_function
    return await validate(query=query)(f)(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/sanic_ext/extras/validation/decorator.py", line 75, in decorated_function
    retval = await retval
             ^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/base_api/pagination.py", line 90, in decorated_function
    items, db_count = await f(request, *args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/connected_services/blueprints.py", line 205, in _get_installations
    installations_list = await self.connected_services_repo.get_oauth2_app_installations(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/renku_data_services/connected_services/db.py", line 346, in get_oauth2_app_installations
    response = await oauth2_client.get(request_url, params=params, headers=adapter.api_common_headers)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/httpx/_client.py", line 1814, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 86, in request
    await self.ensure_active_token(self.token)
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 113, in ensure_active_token
    await self.refresh_token(url, refresh_token=refresh_token)
  File "/app/env/lib/python3.12/site-packages/authlib/integrations/httpx_client/oauth2_client.py", line 149, in _refresh_token
    token = self.parse_response_token(resp)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/env/lib/python3.12/site-packages/authlib/oauth2/client.py", line 355, in parse_response_token
    raise self.oauth_error_class(
authlib.integrations.base_client.errors.OAuthError: bad_refresh_token: The refresh token passed is incorrect or expired.
Srv 0 2024-11-20 07:57:21 +0000 INFO: Token refreshed!
INFO:sanic.root:Token refreshed!
SendEvents 2024-11-20 07:57:22 +0000 INFO: sent 0 events
Srv 0 2024-11-20 07:57:22 +0000 INFO: Token refreshed!
INFO:sanic.root:Token refreshed!
SendEvents 2024-11-20 07:57:23 +0000 INFO: sent 0 events

Concurrent log:

Srv 0 2024-11-20 07:57:19 +0000 INFO: Token refreshed!
INFO:sanic.root:Token refreshed!
leafty commented 6 hours ago

Note that refreshing the UI worked; the UI got the expected responses after a browser refresh.