Skip to content

v2.7.0 breaks when trying to get pathed files #1416

Closed

Description

@xgui3783

Description of the problem, including code/CLI snippet

when trying to

from gitlab import Gitlab
project=Gitlab(GITLAB_SRC).projects.get(GITLAB_PROJECT_ID)
project.files.get(file_path=PATH_TO_FILE, ref=GITLAB_REF)

where PATH_TO_FILE is in the form of {directory}/{filename}, client returns not found error. (see github action: https://github.com/xgui3783/python-gitlab-exmaple/actions/runs/786113706)

I suspect this is due to double escaping the / character from:

Expected Behavior

return file descriptor

Actual Behavior

not found error

Specifications

  • python-gitlab version: v2.7.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): gitlab.com

Activity

  1. added a commit that references this issue on Apr 26, 2021
  2. JohnVillalovos commented on Apr 26, 2021

    @JohnVillalovos
    Member

    This might be related to commit b4dac5c done by @em-

  3. JohnVillalovos commented on Apr 26, 2021

    @JohnVillalovos
    Member

    I do notice that this will happen:

    path/to/file
    path%2fto%2ffile
    path%252fto%252ffile
    

    With this code:

        a = "path/to/file"
        print(a)
        a = a.replace("/", "%2f")
        print(a)
        a = urllib.parse.quote(a, safe="")
        print(a)
    
  4. nejch commented on Apr 26, 2021

    @nejch
    Member

    Yes, I think the get() override for ProjectFileManager (or at least the extra replace) is unnecessary now that the ID is already url-encoded. @JohnVillalovos are you already working on this? Otherwise I'll be pushing a fix tonight.

  5. nejch commented on Apr 26, 2021

    @nejch
    Member

    Related: #1356

  6. JohnVillalovos commented on Apr 26, 2021

    @JohnVillalovos
    Member

    @JohnVillalovos are you already working on this? Otherwise I'll be pushing a fix tonight.

    @nejch No. Sorry I am doing my day-job at the moment. So I can't work on it 😢

  7. nejch commented on Apr 26, 2021

    @nejch
    Member

    @JohnVillalovos are you already working on this? Otherwise I'll be pushing a fix tonight.

    @nejch No. Sorry I am doing my day-job at the moment. So I can't work on it cry

    All good! Just wanted to check, because I'm already looking at this, didn't want us both to work on it at the same time ;)

  8. xgui3783 commented on Apr 26, 2021

    @xgui3783
    Author

    Thanks for the quick fix! 👏👏👏

  9. locked as resolved and limited conversation to collaborators on May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions