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

[BUG] Server Error (500) relating to github get_user_by_id (UnknownObjectException) #948

Closed
mkst opened this issue Feb 2, 2024 · 0 comments · Fixed by #949
Closed

[BUG] Server Error (500) relating to github get_user_by_id (UnknownObjectException) #948

mkst opened this issue Feb 2, 2024 · 0 comments · Fixed by #949

Comments

@mkst
Copy link
Collaborator

mkst commented Feb 2, 2024

Describe the bug

500 error when trying to load a particular scratch that is found on the 2nd page of preset 6.

It appears as if the scratch belongs to a github user that no longer exists.

07:00:21 DEBUG Starting new HTTPS connection (1): api.github.com:443
07:00:21 DEBUG https://api.github.com:443 "GET /user/149795111 HTTP/1.1" 401 80
07:00:42 DEBUG Starting new HTTPS connection (1): api.github.com:443
07:00:42 DEBUG https://api.github.com:443 "GET /user/149795111 HTTP/1.1" 404 105
07:00:42 ERROR Internal Server Error: /api/scratch
Traceback (most recent call last):
  File "/var/www/decomp.me/repo/backend/coreapp/models/github.py", line 63, in details
    details = Github(self.access_token).get_user_by_id(self.github_id)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/MainClass.py", line 325, in get_user_by_id
    headers, data = self.__requester.requestJsonAndCheck("GET", f"/user/{user_id}")
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/Requester.py", line 494, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/Requester.py", line 525, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest"}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/django/views.py", line 84, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
    return view_func(request, *args, **kwargs)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/mixins.py", line 43, in list
    return self.get_paginated_response(serializer.data)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 768, in data
    ret = super().data
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 253, in data
    self._data = self.to_representation(self.instance)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 686, in to_representation
    return [
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 687, in <listcomp>
    self.child.to_representation(item) for item in iterable
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/rest_framework/serializers.py", line 522, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "/var/www/decomp.me/repo/backend/coreapp/serializers.py", line 79, in to_representation
    return serialize_profile(self.context["request"], profile, small=True)
  File "/var/www/decomp.me/repo/backend/coreapp/serializers.py", line 42, in serialize_profile
    github_details = github.details() if github else None
  File "/var/www/decomp.me/repo/backend/coreapp/models/github.py", line 80, in details
    details = Github().get_user_by_id(self.github_id)
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/MainClass.py", line 325, in get_user_by_id
    headers, data = self.__requester.requestJsonAndCheck("GET", f"/user/{user_id}")
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/Requester.py", line 494, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
  File "/home/ethteck/.cache/pypoetry/virtualenvs/backend-xRJ-wtRq-py3.10/lib/python3.10/site-packages/github/Requester.py", line 525, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.UnknownObjectException: 404 {"message": "Not Found", "documentation_url": "https://docs.github.com/rest/users/users#get-a-user"}

To Reproduce

  1. go to https://decomp.me/api/scratch?preset=6&page_size=30
  2. click "Next" an wait for the 500.

Expected behavior
Page should load correctly.

@mkst mkst changed the title [BUG] Server Error (500) relating to github get_user_by_id [BUG] Server Error (500) relating to github get_user_by_id (UnknownObjectException) Feb 2, 2024
@bates64 bates64 linked a pull request Feb 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant