Skip to content

Scope "bug" #806

Closed
Closed

Description

@romansvozil

Description of the problem, including code/CLI snippet

    for job in project.jobs.list(scope=['success', 'failed']):
        print(job.attributes['status'])

It returns jobs of only last scope.
Does python-gitlab api supports multiple scope statement for finding jobs? Because gitlap api yes

Expected Behavior

something like:
success
success
success
failed
success

Actual Behavior

failed
failed
failed

Specifications

  • python-gitlab version:1.8.0
  • API version you are using (v3/v4): v4

Activity

  1. EricTendian commented on Jun 25, 2019

    @EricTendian

    I was able to reproduce this. Turning on my logger to the debug level, it looks like this is the request that is sent:

    https://gitlab.com:443 "GET /api/v4/projects/PROJECT_ID/pipelines/PIPELINE_ID/jobs?scope=success&scope=failed&page=1 HTTP/1.1" 200 1800
    

    The proper request would be GET /api/v4/projects/PROJECT_ID/pipelines/PIPELINE_ID/jobs?scope[]=success&scope[]=failed&page=1 HTTP/1.1 (note the [])

    I'm not confident this is the right way to fix it, but it seems like the ListMixin may need to be updated to properly handle the scope parameter.

  2. duncanwraight commented on Mar 30, 2020

    @duncanwraight

    Was this issue ever resolved? I'm encountering the same thing. Or is there any workaround?

  3. EricTendian commented on Mar 30, 2020

    @EricTendian

    @Duncz don't know if it was resolved, I ended up working around this via not passing a scope but instead filtering the jobs I got in the response (a more expensive operation, but it works).

  4. romansvozil commented on Apr 1, 2020

    @romansvozil
    Author

    @Duncz there is the solution I used in my project:

    scopes = ['pending', 'running', 'failed', 'success']
    jobs = git_project.jobs.list(query_parameters={'scope[]': scopes})

    Should work.

  5. JohnVillalovos commented on Jan 8, 2022

    @JohnVillalovos
    Member

    Related issue: #1735

  6. locked as resolved and limited conversation to collaborators on Jul 31, 2023
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions