Skip to content

gl.runner.all() causes tags to be repeated #2250

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

Open
max-wittig opened this issue Aug 23, 2022 · 1 comment
Open

gl.runner.all() causes tags to be repeated #2250

max-wittig opened this issue Aug 23, 2022 · 1 comment
Labels

Comments

@max-wittig
Copy link
Member

max-wittig commented Aug 23, 2022

Description of the problem, including code/CLI snippet

DEBUG:urllib3.connectionpool:[https://example.gitlab.com:443](https://example.gitlab.com/) "GET /api/v4/runners/all?type=project_type&tag_list=DOCKER HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:[https://example.gitlab.com:443](https://example.gitlab.com/) "GET /api/v4/runners/all?page=2&per_page=20&tag_list%5B%5D=DOCKER&type=project_type&tag_list=DOCKER HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:[https://example.gitlab.com:443](https://example.gitlab.com/) "GET /api/v4/runners/all?page=3&per_page=20&tag_list%5B%5D=DOCKER&type=project_type&tag_list=DOCKER HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:[https://example.gitlab.com:443](https://example.gitlab.com/) "GET /api/v4/runners/all?page=4&per_page=20&tag_list%5B%5D=DOCKER&type=project_type&tag_list=DOCKER HTTP/1.1" 200 None

Expected Behavior

tag_list is only attached once

Actual Behavior

tag_list is attached multiple times

Specifications

  • python-gitlab version: latest
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 15.2.1
@nejch nejch added the bug label Aug 23, 2022
@nejch
Copy link
Member

nejch commented Aug 23, 2022

Seems like we've been doing this for a long time, I can reproduce it with 3.0.0 at least, but probably goes way back.

GitLab converts attribute names of arrays when returning the links headers (tag_list=bla -> tag_list[]=bla), and because the queries differ (attribute vs. attribute[]), requests does not de-duplicate them. We had the same issue with URL-encoding which we fixed here #2219.

For list() calls we should be safe as they track the array attributes and know when to convert them even before sending. Probably 2 options/things to do:

  • add some handling to http_request() to also de-duplicate param vs param[]
  • try to always use ListMixin for any paginated response, and track array attributes (daydream: get it from openapi spec)

I think it's not just runners.all() but any custom method that follows pagination links and is not aware of arrays. At least they are duplicated only once, not appended continuously though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants