Thanks to visit codestin.com
Credit goes to github.com

Skip to content

models.Owner.DoesNotExist: Owner matching query does not exist. #49

@zitsen

Description

@zitsen

When login with github callback, I got a error:

{"error": "Server Error (500)"}

In api container, it raises an error:

{
  "message": "Internal Server Error: /login/github",
  "asctime": "2024-12-18 14:52:45,187",
  "name": "django.request",
  "levelname": "ERROR",
  "lineno": 241,
  "pathname": "/usr/local/lib/python3.12/site-packages/django/utils/log.py",
  "funcName": "log_response",
  "threadName": "MainThread",
  "exc_info": "xxxx",
  "taskName": null,
  "status_code": 500,
  "request": "<WSGIRequest: GET '/login/github?code=xx&state=xx'>",
  "utctime": "2024-12-18T14:52:45.187000",
  "logger.name": "django.request",
  "logger.thread_name": "MainThread",
  "level": "ERROR"
}

The exc_info details:

Traceback (most recent call last):
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/query.py\", line 916, in get_or_create
    return self.get(**kwargs), False
           ^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/query.py\", line 637, in get
    raise self.model.DoesNotExist(
shared.django_apps.codecov_auth.models.Owner.DoesNotExist: Owner matching query does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/usr/local/lib/python3.12/site-packages/django/core/handlers/exception.py\", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/core/handlers/base.py\", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/views/generic/base.py\", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/views/generic/base.py\", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/codecov_auth/views/github.py\", line 139, in get
    return self.actual_login_step(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/codecov_auth/views/github.py\", line 122, in actual_login_step
    owner = self.get_and_modify_owner(user_dict, request)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/codecov_auth/views/base.py\", line 268, in get_and_modify_owner
    owner, is_new_user = self._get_or_create_owner(user_dict, request)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/codecov_auth/views/base.py\", line 363, in _get_or_create_owner
    owner, was_created = Owner.objects.get_or_create(
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/manager.py\", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/query.py\", line 923, in get_or_create
    return self.create(**params), True
           ^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/query.py\", line 658, in create
    obj.save(force_insert=True, using=self.db)
  File \"/usr/local/lib/python3.12/site-packages/shared/django_apps/codecov_auth/models.py\", line 395, in save
    super().save(*args, **kwargs)
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/base.py\", line 814, in save
    self.save_base(
  File \"/usr/local/lib/python3.12/site-packages/model_utils/tracker.py\", line 343, in inner
    return original(instance, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/django/db/models/base.py\", line 892, in save_base
    post_save.send(
  File \"/usr/local/lib/python3.12/site-packages/django/dispatch/dispatcher.py\", line 177, in send
    (receiver, receiver(signal=self, sender=sender, **named))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/codecov_auth/signals.py\", line 53, in update_owner
    ShelterPubsub.get_instance().publish(data)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/app/utils/shelter.py\", line 22, in get_instance
    cls._instance = cls()
                    ^^^^^
  File \"/app/utils/shelter.py\", line 27, in __init__
    self.pubsub_publisher = pubsub_v1.PublisherClient()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/google/cloud/pubsub_v1/publisher/client.py\", line 139, in __init__
    super().__init__(**kwargs)
  File \"/usr/local/lib/python3.12/site-packages/google/pubsub_v1/services/publisher/client.py\", line 492, in __init__
    self._transport = Transport(
                      ^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/google/pubsub_v1/services/publisher/transports/grpc.py\", line 153, in __init__
    super().__init__(
  File \"/usr/local/lib/python3.12/site-packages/google/pubsub_v1/services/publisher/transports/base.py\", line 104, in __init__
    credentials, _ = google.auth.default(
                     ^^^^^^^^^^^^^^^^^^^^
  File \"/usr/local/lib/python3.12/site-packages/google/auth/_default.py\", line 697, in default
    raise exceptions.DefaultCredentialsError(_CLOUD_SDK_MISSING_CREDENTIALS)
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found. To set up Application Default Credentials, see https://cloud.google.com/docs/authentication/external/set-up-adc for more information.

How can I fix this ?

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