0

i have the follwoing :

gl = gitlab.Gitlab(url='https://gitlab.com/',private_token='xxx',api_version=4, session=session)

when am trying to do this :

mrs = gl.mergerequests.list(scope='all',state='opened',visibility='private')

I got :

gitlab.exceptions.GitlabHttpError: 500: 500 Internal Server Error

I tried to increase timeout, retries, retry_transient_errors=True.

but I still got same error.

what am trying to achieve is that I want to list all MR's for private projects no matter if I create it or not.

is there anyway ?

New contributor
mnsh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • Any five hundred HTTP error codes mean errors within the server and shouldn't have anything with your code. Have you checked with GitLab's administrator? 15 hours ago
  • @NiltonMoura no didn't check, i also think that I can't got all MR's with that single line, but maybe that there is some workaround.
    – mnsh
    14 hours ago

1 Answer 1

1

GitlabHttpError: 500 means gitlab responded with a 500 error. The most likely cause of this is that you are requesting too much data at once.

One key issue here is that visibility is not a valid keyword for this method, so it will be completely ignored. This means, in effect, you're asking for all open merge requests on GitLab.com, which would be way too much data to return in a single request, hence GitLab bails out and returns a 500.

To see a valid list of keywords, see the merge requests API documentation.

Unfortunately, this API does not support pagination. As a workaround for this, you can list your relevant projects first using the list projects API which does support visibility as a filter. For each project, you can list all of its merge requests.

Because these endpoints are paginated, it doesn't matter how many projects or MRs there are, you will be able to request them all (with multiple paginated requests, handled by the python-gitlab wrapper)

all_private_mrs = []
for project in gl.projects.list(visibility='private', as_list=False):
    for mr in project.mergerequests.list(as_list=False, state='opened'):
        print(mr)
        all_private_mrs.append(mr)

To speed this up, you can increase the per_page argument and use keyset pagination.

3
  • I already read all keywords, there is some slow workaround is that I wrote bash script which loop between 15 projects that i have access to them and got json for all opened MR, still not a way for me.
    – mnsh
    13 hours ago
  • 1
    @mnsh what about looping over the projects doesn't work for you?
    – sytech
    13 hours ago
  • 1
    thanks a lot, your code is the answer, idk that i can looping over the projects <3.
    – mnsh
    13 hours ago

Your Answer

mnsh is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.