Skip to content

Trying to Fetch multiple ProjectIssues in a single batch call returns only the last ProjectIssue specified in the list #1407

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

Closed
aaronalphonso opened this issue Apr 23, 2021 · 6 comments · Fixed by #1413
Labels

Comments

@aaronalphonso
Copy link

Description of the problem, including code/CLI snippet

According to Gitlab, we can make a batch GET call to fetch multiple issues by passing in the list of issue_ids in parameter iids.

However, while using the library this method call always returns a list with a single element (which happens to be the last element in the iids list.

project = gl.projects.get(project_id)
project.issues.list(all=True, iids=[1, 2, 3])   # Returns a list with a single element ProjectIssue[iid=3]
project.issues.list(all=True, iids=[3, 2, 1])   # Returns a list with a single element ProjectIssue[iid=1]

Are batch requests not supported yet or is this a bug?

Expected Behavior

The batch call should return a list of all ProjectIssues as mentioned in the iids field.

project = gl.projects.get(project_id)
project.issues.list(all=True, iids=[1, 2, 3])   # Should return [ProjectIssue(iid=1), ProjectIssue(iid=2), ProjectIssue(iid=3)]

Actual Behavior

Only the ProjectIssue corresponding to the last id in the iids list is returned

project = gl.projects.get(project_id)
project.issues.list(all=True, iids=[1, 2, 3])    # Returns a list with a single element ProjectIssue[iid=3]

Specifications

  • python-gitlab version: 2.6.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): GitLab Community Edition 13.10.2
@aaronalphonso aaronalphonso changed the title Trying to Fetch multiple ProjectIssues by a single batch call returns only the last ProjectIssue specified in the list Trying to Fetch multiple ProjectIssues in a single batch call returns only the last ProjectIssue specified in the list Apr 23, 2021
@nejch nejch added the bug label Apr 23, 2021
@nejch
Copy link
Member

nejch commented Apr 23, 2021

This seems related to some other issues where lists aren't passed to query params correctly, I'll check. I think we have a similar issue with scopes.

Out of curiosity, have you tried passing the iids as a comma-delimited string? Would need to check what the current state of the gitlab API is with this (see e.g. https://gitlab.com/gitlab-org/gitlab-foss/-/issues/48007)

@aaronalphonso
Copy link
Author

I just tried passing in iids as a comma-delimted string and it gives me the expected results. Thank you very much for the suggestion! :)

@JohnVillalovos
Copy link
Member

JohnVillalovos commented Apr 25, 2021

EDIT: Now I am less sure. I need to do more investigation... I'm pretty sure that the patch as it is right now will not work 😢

I have proposed a patch for this issue in #1413

I'm hopeful that it will work though I have not tested it.

@JohnVillalovos
Copy link
Member

JohnVillalovos commented Apr 25, 2021

EDIT: So after further research believe the problem is python-gitlab. Created issue for it: #1419

I have left a comment on the MR, which seems to have caused this behavior in Gitlab:

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33450

@JohnVillalovos
Copy link
Member

Related issue: #1256

@JohnVillalovos
Copy link
Member

@nejch I think I may have found out our root cause issue.

Had a discussion with a Gitlab developer in: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/33450

From the Gitlab documentation: https://docs.gitlab.com/ee/api/#array

array

import_sources is a parameter of type array:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
-d "import_sources[]=github" \
-d "import_sources[]=bitbucket" \
"https://gitlab.example.com/api/v4/some_endpoint"

So it seems for array types we need to append [] to the variable name.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants