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

better handling of gitlab authentification error #57

Open
svigerske opened this issue Aug 1, 2024 · 1 comment
Open

better handling of gitlab authentification error #57

svigerske opened this issue Aug 1, 2024 · 1 comment

Comments

@svigerske
Copy link
Member

If one has specified a GitLab token, but then there is an authentication error (e.g., because the token expired), then this leads to some uncaught exception:

01-08-2024 09:41:46 - 741 ERROR tornado.application Uncaught exception GET / (127.0.0.1)
HTTPServerRequest(protocol='http', host='rubberband.zib.de:443', method='GET', uri='/', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 1569, in _execute
    result = self.prepare()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 27, in prepare
    self.current_user = self.get_current_user()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 84, in get_current_user
    self.access_level = get_user_access_level(email)
  File "/opt/rubberband/package-20170825173100/rubberband/utils/gitlab.py", line 48, in get_user_access_level
    group_users = client.groups.get(group_id).members.list(query=user_mail)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
    return f(*args, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/mixins.py", line 49, in get
    server_data = self.gitlab.http_get(path, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 532, in http_get
    streamed=streamed, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 506, in http_request
    response_body=result.content)
gitlab.exceptions.GitlabAuthenticationError: 401: invalid_token
01-08-2024 09:41:46 - 815 ERROR tornado.application Uncaught exception in write_error
Traceback (most recent call last):
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 1569, in _execute
    result = self.prepare()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 27, in prepare
    self.current_user = self.get_current_user()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 84, in get_current_user
    self.access_level = get_user_access_level(email)
  File "/opt/rubberband/package-20170825173100/rubberband/utils/gitlab.py", line 48, in get_user_access_level
    group_users = client.groups.get(group_id).members.list(query=user_mail)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
    return f(*args, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/mixins.py", line 49, in get
    server_data = self.gitlab.http_get(path, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 532, in http_get
    streamed=streamed, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 506, in http_request
    response_body=result.content)
gitlab.exceptions.GitlabAuthenticationError: 401: invalid_token

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 1112, in send_error
    self.write_error(status_code, **kwargs)
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 162, in write_error
    self.render("error.html", status_code=status_code, page_title=reason, msg=log_message)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 766, in render
    html = self.render_string(template_name, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 905, in render_string
    namespace = self.get_template_namespace()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 175, in get_template_namespace
    namespace = super(BaseHandler, self).get_template_namespace()
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 921, in get_template_namespace
    current_user=self.current_user,
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/tornado/web.py", line 1233, in current_user
    self._current_user = self.get_current_user()
  File "/opt/rubberband/package-20170825173100/rubberband/handlers/fe/base.py", line 84, in get_current_user
    self.access_level = get_user_access_level(email)
  File "/opt/rubberband/package-20170825173100/rubberband/utils/gitlab.py", line 48, in get_user_access_level
    group_users = client.groups.get(group_id).members.list(query=user_mail)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/exceptions.py", line 251, in wrapped_f
    return f(*args, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/mixins.py", line 49, in get
    server_data = self.gitlab.http_get(path, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 532, in http_get
    streamed=streamed, **kwargs)
  File "/opt/rubberband/production/venv/lib/python3.6/site-packages/gitlab/__init__.py", line 506, in http_request
    response_body=result.content)
gitlab.exceptions.GitlabAuthenticationError: 401: invalid_token
01-08-2024 09:41:46 - 815 ERROR tornado.access  500 GET / (127.0.0.1) 121.41ms

It would be really nice if the exception were caught and Rubberband would display some useful warning or error message instead of a 500 - internal server error.

@svigerske
Copy link
Member Author

Also get exceptions at similar point if not specifying any GitLab URL. So the GitLab connection does not seem to be as optional as claimed in the README.

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

No branches or pull requests

1 participant