Skip to content

Suggestion: url encode project paths automatically #1498

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
chris-peterson opened this issue Jun 3, 2021 · 3 comments · Fixed by #1790
Closed

Suggestion: url encode project paths automatically #1498

chris-peterson opened this issue Jun 3, 2021 · 3 comments · Fixed by #1790
Labels

Comments

@chris-peterson
Copy link

Description of the problem, including code/CLI snippet

Would be nice to not have to url-encode project paths when calling project APIs. Feels pretty safe to replace / with %2F and not break folks

Expected Behavior

Allow project paths to contain / without any escaping/encoding

Actual Behavior

Results in 404s, project not found. have to url encode and try again.

Specifications

  • python-gitlab version: 2.7.1
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 13.10.3
@nejch
Copy link
Member

nejch commented Jun 3, 2021

Hi @chris-peterson thanks, can you give some examples of endpoints that don't allow project paths to have /?

Things like gl.projects.get("path/to/project") should already work. Or did I misunderstand the issue? :)

@chris-peterson
Copy link
Author

@nejch -- I am grateful that the get function will accept non-encoded project ids. the suggestion is for other APIs, e.g. updating a project. here's an example:

works:
gitlab project update --id 'mygroup%2Fmyproject' --tag-list 'some value'

fails:
gitlab project update --id 'mygroup/myproject' --tag-list 'some value'

my workaround so far has been to either:

  1. url encode project ids before calling APIs OR
  2. always look up the integer ID first and pass that instead

@nejch nejch added the cli label Jun 3, 2021
@nejch
Copy link
Member

nejch commented Jun 3, 2021

Thanks! I see, so this is mostly an issue with the CLI as with the API you would usually first get the object (even if lazily), but we should update this, it should be a few one-liners. Thanks for the report!

Related to #1356

JohnVillalovos added a commit that referenced this issue Jan 8, 2022
In the CLI we need to make sure the components put into the path
portion of the URL are url-encoded. Otherwise they will be interpreted
as part of the path. For example can specify the project ID as a path,
but in the URL it must be url-encoded or it doesn't work.

Also stop adding the components of the path as query parameters in the
URL.

Closes: #783
Closes: #1498
JohnVillalovos added a commit that referenced this issue Jan 8, 2022
In the CLI we need to make sure the components put into the path
portion of the URL are url-encoded. Otherwise they will be interpreted
as part of the path. For example can specify the project ID as a path,
but in the URL it must be url-encoded or it doesn't work.

Also stop adding the components of the path as query parameters in the
URL.

Closes: #783
Closes: #1498
JohnVillalovos added a commit that referenced this issue Jan 8, 2022
In the CLI we need to make sure the components put into the path
portion of the URL are url-encoded. Otherwise they will be interpreted
as part of the path. For example can specify the project ID as a path,
but in the URL it must be url-encoded or it doesn't work.

Also stop adding the components of the path as query parameters in the
URL.

Closes: #783
Closes: #1498
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2023
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.

2 participants