Skip to content

fix: iids not working as a list in projects.issues.list() #1413

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

Merged
merged 1 commit into from
Apr 27, 2021
Merged

fix: iids not working as a list in projects.issues.list() #1413

merged 1 commit into from
Apr 27, 2021

Conversation

JohnVillalovos
Copy link
Member

@JohnVillalovos JohnVillalovos commented Apr 25, 2021

Set the 'iids' values as type ListAttribute so it will pass the list
as a comma-separated string, instead of a list.

Closes: #1407

@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2021

Codecov Report

Merging #1413 (265bc13) into master (dde01c7) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1413   +/-   ##
=======================================
  Coverage   80.24%   80.24%           
=======================================
  Files          73       73           
  Lines        4064     4064           
=======================================
  Hits         3261     3261           
  Misses        803      803           
Flag Coverage Δ
unit 80.24% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gitlab/v4/objects/issues.py 80.88% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dde01c7...265bc13. Read the comment docs.

@JohnVillalovos
Copy link
Member Author

This doesn't work at the moment. ListAttribute assumes the input is a string.

@JohnVillalovos JohnVillalovos marked this pull request as ready for review April 25, 2021 22:48
@JohnVillalovos
Copy link
Member Author

JohnVillalovos commented Apr 25, 2021

This depends on #1415 getting merged or this whole patch chain could be merged and #1415 could be closed.

@JohnVillalovos
Copy link
Member Author

JohnVillalovos commented Apr 25, 2021

I tested this and reproduced the issue and then with my change it worked correctly.

Likely I should probably update this patch to cover all the other instances of iids

I think all of these API endpoints would need to be updated. This is searching the GitLab source code for users of CommaSeparatedToIntegerArray.

~/source/gitlab/ $ rg --sort path 'coerce_with.*CommaSeparatedToIntegerArray'
doc/development/api_styleguide.md
120:optional :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The user ids for this rule'

ee/lib/api/geo_nodes.rb
51:        optional :selective_sync_namespace_ids, as: :namespace_ids, type: Array[Integer], coerce_with: Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IDs of groups that should be synced, if `selective_sync_type` == `namespaces`'
208:          optional :selective_sync_namespace_ids, as: :namespace_ids, type: Array[Integer], coerce_with: Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IDs of groups that should be synced, if `selective_sync_type` == `namespaces`'

ee/lib/api/helpers/project_approval_rules_helpers.rb
12:        optional :users, as: :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The user ids for this rule'
13:        optional :groups, as: :group_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The group ids for this rule'
14:        optional :protected_branch_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The protected branch ids for this rule'
21:        optional :users, as: :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The user ids for this rule'
22:        optional :groups, as: :group_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The group ids for this rule'
23:        optional :protected_branch_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The protected branch ids for this rule'

ee/lib/api/merge_request_approval_rules.rb
35:          optional :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The user ids for this rule'
36:          optional :group_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The group ids for this rule'
57:            optional :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The user ids for this rule'
58:            optional :group_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The group ids for this rule'

ee/lib/api/project_approvals.rb
65:        requires :approver_ids, type: Array[Integer], coerce_with: Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Array of User IDs to set as approvers.'
66:        requires :approver_group_ids, type: Array[Integer], coerce_with: Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Array of Group IDs to set as approvers.'

ee/lib/ee/api/helpers/settings_helpers.rb
29:              optional :elasticsearch_namespace_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The namespace ids to index with Elasticsearch.'
30:              optional :elasticsearch_project_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The project ids to index with Elasticsearch.'

ee/lib/ee/api/merge_request_approvals.rb
87:              requires :approver_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce,
89:              requires :approver_group_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce,

lib/api/groups.rb
21:        optional :skip_groups, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Array of group ids to exclude from list'

lib/api/issues.rb
17:        optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IID array of issues'
69:        optional :assignee_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The array of user IDs to assign issue'

lib/api/members.rb
23:          optional :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Array of user ids to look up for membership'
42:          optional :user_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Array of user ids to look up for membership'

lib/api/merge_requests.rb
162:          optional :assignee_ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The array of user IDs to assign issue'
182:        optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IID array of merge requests'

lib/api/milestone_responses.rb
18:          optional :iids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'The IIDs of the milestones'

lib/api/projects.rb
549:        optional :skip_users, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: 'Filter out users with the specified IDs'

lib/api/suggestions.rb
28:        requires :ids, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce, desc: "An array of suggestion ID's"

spec/lib/api/helpers/common_helpers_spec.rb
20:        optional :array_of_ints, type: Array[Integer], coerce_with: ::API::Validations::Types::CommaSeparatedToIntegerArray.coerce

@JohnVillalovos
Copy link
Member Author

JohnVillalovos commented Apr 27, 2021

@nejch I added a functional test that shows this works. I tried the functional test first without the fix and it failed.

Failed functional test without fix: https://github.com/python-gitlab/python-gitlab/runs/2449139416?check_suite_focus=true

Set the 'iids' values as type ListAttribute so it will pass the list
as a comma-separated string, instead of a list.

Add a functional test.

Closes: #1407
@nejch
Copy link
Member

nejch commented Apr 27, 2021

@nejch I added a functional test that shows this works. I tried the functional test first without the fix and it failed.

Failed functional test without fix: https://github.com/python-gitlab/python-gitlab/runs/2449139416?check_suite_focus=true

Awesome! i just trust functional tests so much more because they catch these real issues and behavior. Thanks :)

@nejch nejch enabled auto-merge April 27, 2021 15:24
@nejch nejch merged commit a6b6cd4 into python-gitlab:master Apr 27, 2021
@JohnVillalovos JohnVillalovos deleted the jlvillal/1407 branch April 27, 2021 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants