Skip to content

ProjectMergeRequest.pipelines() returns a 'list' instead of documented 'RESTObjectList' #1312

Closed

Description

@beanaroo

Description of the problem, including code/CLI snippet

I'm not sure if this is a documentation or API bug.

type(merge_request.pipelines(order_by='created_at'))
<class 'list'>

Documentation suggests it is RESTObjectList

Getting an element in the returned list by index (pipelines()[0]) works but produces the following warning.

Class 'RESTObjectList' does not define '__getitem__', so the '[]' operator cannot be used on its instances

Specifications

  • python-gitlab version: 2.6.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): gitlab.com

Activity

  1. nejch commented on Feb 21, 2021

    @nejch
    Member

    Seems like the MR pipelines endpoint has a custom method that only does http_get() at the moment that just serializes the json:

    def pipelines(self, **kwargs):
    """List the merge request pipelines.
    Args:
    **kwargs: Extra options to send to the server (e.g. sudo)
    Raises:
    GitlabAuthenticationError: If authentication is not correct
    GitlabListError: If the list could not be retrieved
    Returns:
    RESTObjectList: List of changes
    """
    path = "%s/%s/pipelines" % (self.manager.path, self.get_id())
    return self.manager.gitlab.http_get(path, **kwargs)

    Hmm, it's an easy fix but might be better to deprecate this and add proper managers to MRs now that they also have a create pipeline API endpoint and call them like project pipelines:

    merge_request.pipelines.list()
    merge_request.pipelines.create()

    Related to #1239

  2. nejch commented on Feb 23, 2021

    @nejch
    Member

    @beanaroo this should be fixed when #1323 is merged and released, but then please switch to the list() method asap as the old one will be removed.

    BTW it will still return a list with this new method, unless you specifically ask for a generator (as_list=False), but at least the docstrings will be accurate.

  3. msune commented on Mar 27, 2021

    @msune

    Hi,

    Wondering if what I see is remotely related.

    mr.pipelines() doesn't seem to honour all=True (that particular MR has 140+ pipelines):

    ipdb> len(mr.pipelines())
    20
    ipdb> len(mr.pipelines(all=True, lazy=False))
    20
    

    However, trying directly the REST API with per_page=100, which I believe is the max as per Gitlab's docs, returns the first 100 elements:

    https://gitlab.acme.com/api/v4//projects/59/merge_requests/1307/pipelines?per_page=100`
    

    Am I missing something fundamental here? Should I open a separate issue or is it related?

  4. nejch commented on May 1, 2021

    @nejch
    Member

    @msune yes this is most likely related because all=True is implemented via http_list. So this will be fixed after merging the PR linked above.

  5. locked as resolved and limited conversation to collaborators on Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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