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

🐛 Fix URL serialization in /invitations:extract endpoint #6808

Merged

Conversation

giancarloromeo
Copy link
Contributor

@giancarloromeo giancarloromeo commented Nov 22, 2024

What do these changes do?

Fix the invitation URL serialization in the request body when hitting the /invitations:extract endpoint.

Unable to process your invitation since the invitations service is currently unavailable [OEC:138117572806592].
{'context': "{'code': "
            "'ValueError.WebServerBaseError.InvitationsError.InvitationsServiceUnavailableError',
"
            " 'message': 'Cannot process invitations',
"
            " 'unexpected_error': TypeError('Object of type Url is not JSON "
            "serializable')}",
 'error_code': 'OEC:138117572806592',
 'exception_details': 'Cannot process invitations',
 'exception_type': '<class '
                   "'simcore_service_webserver.invitations.errors.InvitationsServiceUnavailableError'>",
 'tip': 'Something went wrong communicating the `invitations` service'}
Traceback (most recent call last):
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/invitations/_core.py", line 32, in _handle_exceptions_as_invitations_errors
    yield  # API function calls happen
    ^^^^^
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/invitations/_core.py", line 100, in validate_invitation_url
    invitation = await invitations_service.extract_invitation(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/invitations/_client.py", line 85, in extract_invitation
    response = await self.client.post(
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scu/.venv/lib/python3.11/site-packages/aiohttp/client.py", line 409, in _request
    data = payload.JsonPayload(json, dumps=self._json_serialize)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scu/.venv/lib/python3.11/site-packages/aiohttp/payload.py", line 398, in __init__
    dumps(value).encode(encoding),
    ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Url is not JSON serializable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/login/_registration.py", line 213, in _invitations_request_context
    yield url
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/login/_registration.py", line 281, in check_and_consume_invitation
    content = await validate_invitation_url(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/invitations/_core.py", line 93, in validate_invitation_url
    with _handle_exceptions_as_invitations_errors():
  File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/scu/.venv/lib/python3.11/site-packages/simcore_service_webserver/invitations/_core.py", line 58, in _handle_exceptions_as_invitations_errors
    raise InvitationsServiceUnavailableError(
simcore_service_webserver.invitations.errors.InvitationsServiceUnavailableError: Cannot process invitations

Related issue/s

How to test

Dev-ops checklist

@giancarloromeo giancarloromeo self-assigned this Nov 22, 2024
@giancarloromeo giancarloromeo added a:webserver issue related to the webserver service a:invitations invitations service labels Nov 22, 2024
@giancarloromeo giancarloromeo added this to the Event Horizon milestone Nov 22, 2024
@giancarloromeo giancarloromeo marked this pull request as ready for review November 22, 2024 11:51
@giancarloromeo giancarloromeo enabled auto-merge (squash) November 22, 2024 11:52
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.20%. Comparing base (a703f56) to head (2081202).

❗ There is a different number of reports uploaded between BASE (a703f56) and HEAD (2081202). Click for more details.

HEAD has 27 uploads less than BASE
Flag BASE (a703f56) HEAD (2081202)
unittests 31 4
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6808      +/-   ##
==========================================
- Coverage   87.94%   82.20%   -5.74%     
==========================================
  Files        1550      619     -931     
  Lines       61749    32457   -29292     
  Branches     2164      400    -1764     
==========================================
- Hits        54303    26682   -27621     
+ Misses       7117     5705    -1412     
+ Partials      329       70     -259     
Flag Coverage Δ
integrationtests 64.80% <ø> (-7.71%) ⬇️
unittests 87.17% <ø> (+0.75%) ⬆️
Components Coverage Δ
api ∅ <ø> (∅)
pkg_aws_library ∅ <ø> (∅)
pkg_dask_task_models_library ∅ <ø> (∅)
pkg_models_library ∅ <ø> (∅)
pkg_notifications_library ∅ <ø> (∅)
pkg_postgres_database ∅ <ø> (∅)
pkg_service_integration ∅ <ø> (∅)
pkg_service_library ∅ <ø> (∅)
pkg_settings_library ∅ <ø> (∅)
pkg_simcore_sdk 78.10% <ø> (-7.26%) ⬇️
agent ∅ <ø> (∅)
api_server ∅ <ø> (∅)
autoscaling ∅ <ø> (∅)
catalog ∅ <ø> (∅)
clusters_keeper ∅ <ø> (∅)
dask_sidecar ∅ <ø> (∅)
datcore_adapter ∅ <ø> (∅)
director ∅ <ø> (∅)
director_v2 77.40% <ø> (-13.74%) ⬇️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 59.86% <ø> (-29.89%) ⬇️
efs_guardian ∅ <ø> (∅)
invitations ∅ <ø> (∅)
osparc_gateway_server 80.58% <ø> (-4.91%) ⬇️
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage ∅ <ø> (∅)
webclient ∅ <ø> (∅)
webserver 88.69% <ø> (+1.54%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a703f56...2081202. Read the comment docs.

---- 🚨 Try these New Features:

@giancarloromeo giancarloromeo merged commit 532c977 into ITISFoundation:master Nov 25, 2024
86 of 90 checks passed
@giancarloromeo giancarloromeo deleted the fix-invitation-url branch November 26, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:invitations invitations service a:webserver issue related to the webserver service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants