Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: use the [] after key names for array variables inparams#1699

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/arrays
Jul 27, 2022

Conversation

JohnVillalovos
Copy link
Member

@JohnVillalovosJohnVillalovos commentedNov 19, 2021
edited by nejch
Loading

  1. If a value is of type ArrayAttribute then append '[]' to the name
    of the value.

This is step 3 in a series of steps of our goal to add full
support for the GitLab API data types[1]:

  • array
  • hash
  • array of hashes

Step one was: commit5127b15
Step two was: commita57334f

Fixes:#1698
Related to#780
Closes#806

[1]https://docs.gitlab.com/ee/api/#encoding-api-parameters-of-array-and-hash-types

@JohnVillalovosJohnVillalovosforce-pushed thejlvillal/arrays branch 7 times, most recently from98172f6 tof596068CompareNovember 19, 2021 04:22
@JohnVillalovosJohnVillalovos marked this pull request as draftNovember 19, 2021 04:23
@JohnVillalovosJohnVillalovos changed the titleWIP: Trying to solve array issuefix: use the [] after key names for array variablesNov 19, 2021
@codecov-commenter
Copy link

codecov-commenter commentedNov 19, 2021
edited
Loading

Codecov Report

Merging#1699 (1af44ce) intomain (194ee01) willdecrease coverage by0.00%.
The diff coverage is96.42%.

@@            Coverage Diff             @@##             main    #1699      +/-   ##==========================================- Coverage   95.54%   95.53%   -0.01%==========================================  Files          81       81                Lines        5296     5309      +13     ==========================================+ Hits         5060     5072      +12- Misses        236      237       +1
FlagCoverage Δ
api_func_v481.48% <85.71%> (+<0.01%)⬆️
cli_func_v482.82% <46.42%> (-0.30%)⬇️
unit87.28% <92.85%> (-0.01%)⬇️

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

Impacted FilesCoverage Δ
gitlab/utils.py98.59% <92.85%> (-1.41%)⬇️
gitlab/mixins.py92.30% <100.00%> (ø)
gitlab/types.py98.21% <100.00%> (+0.13%)⬆️

@JohnVillalovos
Copy link
MemberAuthor

JohnVillalovos commentedNov 20, 2021
edited
Loading

So in my testing this does not break anything. It also allowsapprover_ids andapproved_by_ids to work forONE specified user (before it just failed) in listing merge requests. But it does not work for two or more, as it just returns the match for the first one.

I'm not a fan of the silent failure as that is likely worse than current situation where it dies.

@JohnVillalovosJohnVillalovosforce-pushed thejlvillal/arrays branch 6 times, most recently fromdb3ab50 toe3c2e95CompareNovember 20, 2021 21:30
@JohnVillalovosJohnVillalovos marked this pull request as ready for reviewNovember 20, 2021 21:30
@JohnVillalovos
Copy link
MemberAuthor

@nejch This is ready for review now. Interested to hear your feedback. Thanks.

@JohnVillalovosJohnVillalovos marked this pull request as draftApril 16, 2022 18:48
@nejch
Copy link
Member

Should we try to revive this one@JohnVillalovos? Seems like an important fix. Probably fixes a few more issues down the line, will need to check those.

@JohnVillalovos
Copy link
MemberAuthor

Should we try to revive this one@JohnVillalovos? Seems like an important fix. Probably fixes a few more issues down the line, will need to check those.

Yeah, probably. Let me see if I get some time this weekend. Thanks for reminding me!

@JohnVillalovosJohnVillalovos marked this pull request as ready for reviewJuly 24, 2022 21:13
@JohnVillalovosJohnVillalovos marked this pull request as draftJuly 24, 2022 21:30
@JohnVillalovosJohnVillalovosforce-pushed thejlvillal/arrays branch 2 times, most recently from7f6a8c2 to50b1f12CompareJuly 25, 2022 23:55
@JohnVillalovosJohnVillalovos marked this pull request as ready for reviewJuly 25, 2022 23:56
@JohnVillalovos
Copy link
MemberAuthor

@nejch It is ready for review again. Thanks for your patience.

Copy link
Member

@nejchnejch left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks@JohnVillalovos looks super simple now. I have some concerns but I think I'll just merge this and use it to track and open a refactor based on my comments.

I have to take that back - seems like this also transforms the key for POST/PUT payloads which shouldn't happen. This maybe needs a test withcreate() to ensure we don't usekey[] in payloads.

Edit2: I think we need to maybe change_transform_types to take another argument (transform_keys) which we pass in in the ListMixin or maybe even directly in get requests.

@nejchnejch changed the titlefix: use the [] after key names for array variablesfix: use the [] after key names for array variables in GET requestsJul 26, 2022
@JohnVillalovos
Copy link
MemberAuthor

I have to take that back - seems like this also transforms the key for POST/PUT payloads which shouldn't happen. This maybe needs a test withcreate() to ensure we don't usekey[] in payloads.

I think we need to transform "parameters'. Whether it is a GET/POST/PUT. Now handling values in thedata portion is a different thing we need to figure out.

@nejch
Copy link
Member

I have to take that back - seems like this also transforms the key for POST/PUT payloads which shouldn't happen. This maybe needs a test withcreate() to ensure we don't usekey[] in payloads.

I think we need to transform "parameters'. Whether it is a GET/POST/PUT. Now handling values in thedata portion is a different thing we need to figure out.

Yes, that's right :) sorry for the confusion. payload = no transform, query params = transform.

@JohnVillalovosJohnVillalovos changed the titlefix: use the [] after key names for array variables in GET requestsfix: use the [] after key names for array variablesJul 27, 2022
@nejch
Copy link
Member

@JohnVillalovos I think this doesn't work quite right yet. Can you try this test in this patch?

diff --git a/tests/unit/mixins/test_mixin_methods.py b/tests/unit/mixins/test_mixin_methods.pyindex 69cdb78..e8870b9 100644--- a/tests/unit/mixins/test_mixin_methods.py+++ b/tests/unit/mixins/test_mixin_methods.py@@ -314,6 +314,26 @@ def test_create_mixin_custom_path(gl):     assert responses.assert_call_count(url, 1) is True++@responses.activate+def test_create_mixin_with_attributes(gl):+    class M(CreateMixin, FakeManager):+        _types = {"my_array": gl_types.ArrayAttribute}++    url = "http://localhost/api/v4/tests"+    responses.add(+        method=responses.POST,+        headers={},+        url=url,+        json={},+        status=200,+        match=[responses.matchers.json_params_matcher({"my_array": ["1", "2", "3"]})],+    )++    mgr = M(gl)+    mgr.create({"my_array": [1, 2, 3]})++ def test_update_mixin_missing_attrs(gl):     class M(UpdateMixin, FakeManager):         _update_attrs = gl_types.RequiredOptional(

The reason we might want this is, for examplescopes as an array in create mixins for#780.

@JohnVillalovos
Copy link
MemberAuthor

JohnVillalovos commentedJul 27, 2022
edited
Loading

@JohnVillalovos I think this doesn't work quite right yet. Can you try this test in this patch?

Thanks@nejch I totally missed that thedata was not being sent asparams in the POST/PUT methods 😔

Updated the code to only modify the data for thelist() method.

1. If a value is of type ArrayAttribute then append '[]' to the name   of the value for query parameters (`params`).This is step 3 in a series of steps of our goal to add fullsupport for the GitLab API data types[1]:  * array  * hash  * array of hashesStep one was: commit5127b15Step two was: commita57334fFixes:#1698[1]https://docs.gitlab.com/ee/api/#encoding-api-parameters-of-array-and-hash-types
@JohnVillalovosJohnVillalovos changed the titlefix: use the [] after key names for array variablesfix: use the [] after key names for array variables inparamsJul 27, 2022
@nejchnejch merged commit510ec30 intomainJul 27, 2022
@nejchnejch deleted the jlvillal/arrays branchJuly 27, 2022 23:24
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nejchnejchnejch left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

List merge requests using specific approver_ids regression Scope "bug"
3 participants
@JohnVillalovos@codecov-commenter@nejch

[8]ページ先頭

©2009-2025 Movatter.jp