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

Raise error when GitLab module fails to connect #154

Closed
jhutar opened this issue Oct 30, 2018 · 1 comment
Closed

Raise error when GitLab module fails to connect #154

jhutar opened this issue Oct 30, 2018 · 1 comment
Assignees

Comments

@jhutar
Copy link

jhutar commented Oct 30, 2018

What about this?

diff --git a/did/plugins/gitlab.py b/did/plugins/gitlab.py
index b546e44..52f75d8 100644
--- a/did/plugins/gitlab.py
+++ b/did/plugins/gitlab.py
@@ -69,6 +69,7 @@ class GitLab(object):
             self, endpoint, since=None, get_all_results=False):
         results = []
         result = self._get_gitlab_api(endpoint)
+        result.raise_for_status()
         results.extend(result.json())
         while ('next' in result.links and 'url' in result.links['next'] and
                 get_all_results):

or maybe just a warning like:

if not result.ok:
    logging.warning("Error {0}: {1}".format(result.status_code, result.text))

In my case, looks like I'm using some buggy GitLab version and API token with "read_user" was not enough. I have been experimenting for some time and discovered GitLab was correctly giving me the reason, but it was hidden:

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://.../api/v4/users/1333/events?after=2018-10-01&before=2018-11-02
@psss psss changed the title when GitLab module fails to connect (e.g. with 403 status code), it toes not show actuall error Raise error when GitLab module fails to connect Nov 26, 2018
@psss psss self-assigned this Nov 26, 2018
@psss psss added the bug label Nov 26, 2018
@psss
Copy link
Owner

psss commented Nov 26, 2018

Makes sense, thanks for the patch.

@psss psss added the plugins label Nov 26, 2018
@psss psss closed this as completed in fad869b Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants