Skip to content

fix: use url-encoded ID in all paths #1819

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 3 commits into from
Jan 13, 2022
Merged

fix: use url-encoded ID in all paths #1819

merged 3 commits into from
Jan 13, 2022

Conversation

JohnVillalovos
Copy link
Member

Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079

@JohnVillalovos JohnVillalovos marked this pull request as draft January 9, 2022 02:41
@JohnVillalovos JohnVillalovos marked this pull request as ready for review January 9, 2022 02:47
@JohnVillalovos JohnVillalovos requested a review from nejch January 9, 2022 02:47
@codecov-commenter
Copy link

codecov-commenter commented Jan 9, 2022

Codecov Report

Merging #1819 (2d9612b) into main (824151c) will decrease coverage by 0.02%.
The diff coverage is 65.11%.

@@            Coverage Diff             @@
##             main    #1819      +/-   ##
==========================================
- Coverage   92.19%   92.17%   -0.03%     
==========================================
  Files          77       77              
  Lines        4819     4843      +24     
==========================================
+ Hits         4443     4464      +21     
- Misses        376      379       +3     
Flag Coverage Δ
cli_func_v4 81.33% <27.13%> (-0.02%) ⬇️
py_func_v4 80.19% <57.36%> (+0.03%) ⬆️
unit 83.19% <34.10%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
gitlab/v4/objects/epics.py 74.41% <0.00%> (ø)
gitlab/v4/objects/features.py 68.42% <0.00%> (ø)
gitlab/v4/objects/geo_nodes.py 68.57% <0.00%> (ø)
gitlab/v4/objects/merge_request_approvals.py 90.58% <0.00%> (ø)
gitlab/v4/objects/groups.py 87.96% <33.33%> (ø)
gitlab/v4/objects/jobs.py 77.27% <33.33%> (ø)
gitlab/v4/objects/projects.py 87.19% <33.33%> (ø)
gitlab/v4/objects/repositories.py 83.07% <55.55%> (ø)
gitlab/v4/objects/merge_requests.py 84.78% <62.50%> (ø)
gitlab/mixins.py 91.50% <65.00%> (-0.05%) ⬇️
... and 10 more

JohnVillalovos added a commit that referenced this pull request Jan 9, 2022
An alternative to #1819

Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079
JohnVillalovos added a commit that referenced this pull request Jan 9, 2022
An alternative to #1819

Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079
JohnVillalovos added a commit that referenced this pull request Jan 9, 2022
An alternative to #1819

Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079
JohnVillalovos added a commit that referenced this pull request Jan 9, 2022
An alternative to #1819

Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079
@JohnVillalovos JohnVillalovos marked this pull request as draft January 9, 2022 08:55
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 2 times, most recently from 9b40dda to 54abe80 Compare January 9, 2022 20:09
@JohnVillalovos JohnVillalovos marked this pull request as ready for review January 9, 2022 20:09
@JohnVillalovos JohnVillalovos requested a review from nejch January 9, 2022 20:09
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 3 times, most recently from 9896154 to f9fed09 Compare January 10, 2022 02:55
@JohnVillalovos JohnVillalovos requested a review from nejch January 10, 2022 05:41
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 3 times, most recently from c865920 to af3f5ae Compare January 10, 2022 06:31
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Thanks for the update again! Just a few questions from me :)

@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 2 times, most recently from a5ff3b5 to 826a03f Compare January 11, 2022 02:11
@JohnVillalovos JohnVillalovos requested a review from nejch January 11, 2022 02:12
@JohnVillalovos JohnVillalovos requested a review from nejch January 13, 2022 17:33
Make sure all usage of the ID in the URL path is encoded. Normally it
isn't an issue as most IDs are integers or strings which don't contain
a slash ('/'). But when the ID is a string with a slash character it
will break things.

Add a test case that shows this fixes wikis issue with subpages which
use the slash character.

Closes: #1079
Add EncodedId string class. This class returns a URL-encoded string
but ensures it will only URL-encode it once even if recursively
called.

Also added some functional tests of 'lazy' objects to make sure they
work.
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 2 times, most recently from a3983fc to 2d9612b Compare January 13, 2022 18:47
@JohnVillalovos JohnVillalovos requested a review from nejch January 13, 2022 18:58
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/encoded_id branch 3 times, most recently from 16f725f to a05ee47 Compare January 13, 2022 19:12
@JohnVillalovos JohnVillalovos requested a review from nejch January 13, 2022 19:16
utils.EncodedId() has basically the same functionalityy of using
utils._url_encode(). So remove utils._url_encode() as we don't need
it.
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

Awesome @JohnVillalovos this will fix like 90% of the CLI path issues for sub-resources :)

@nejch nejch merged commit bc48840 into main Jan 13, 2022
@nejch nejch deleted the jlvillal/encoded_id branch January 13, 2022 19:48
@JohnVillalovos
Copy link
Member Author

Thanks for all the reviews @nejch Looks a LOT better from where I started 😊

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

Successfully merging this pull request may close these issues.

project.wikis.create with subpages results in 404 Wiki Page Not Found
3 participants