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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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 79.42%. Comparing base (ca228c3) to head (07e98d9).

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

HEAD has 28 uploads less than BASE
Flag BASE (ca228c3) HEAD (07e98d9)
unittests 31 3
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6808      +/-   ##
==========================================
- Coverage   88.42%   79.42%   -9.01%     
==========================================
  Files        1545      615     -930     
  Lines       61627    30853   -30774     
  Branches     2157      263    -1894     
==========================================
- Hits        54495    24505   -29990     
+ Misses       6803     6288     -515     
+ Partials      329       60     -269     
Flag Coverage Δ
integrationtests 64.75% <ø> (ø)
unittests 82.28% <ø> (-4.06%) ⬇️
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 77.36% <ø> (-8.00%) ⬇️
agent ∅ <ø> (∅)
api_server ∅ <ø> (∅)
autoscaling ∅ <ø> (∅)
catalog ∅ <ø> (∅)
clusters_keeper ∅ <ø> (∅)
dask_sidecar ∅ <ø> (∅)
datcore_adapter ∅ <ø> (∅)
director ∅ <ø> (∅)
director_v2 76.53% <ø> (-14.61%) ⬇️
dynamic_scheduler ∅ <ø> (∅)
dynamic_sidecar 59.86% <ø> (-29.86%) ⬇️
efs_guardian ∅ <ø> (∅)
invitations ∅ <ø> (∅)
osparc_gateway_server 79.79% <ø> (-5.70%) ⬇️
payments ∅ <ø> (∅)
resource_usage_tracker ∅ <ø> (∅)
storage ∅ <ø> (∅)
webclient ∅ <ø> (∅)
webserver 84.10% <ø> (-4.60%) ⬇️

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 ca228c3...07e98d9. Read the comment docs.

---- 🚨 Try these New Features:

Copy link

sonarcloud bot commented Nov 22, 2024

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.

4 participants