8000 ProjectFileManager.create doesn't cope with deep paths (file_path with slashes) · Issue #339 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content
ProjectFileManager.create doesn't cope with deep paths (file_path with slashes) #339
Closed
@mgoodhand

Description

@mgoodhand

I've been trying to use gitlab.v4.objects.ProjectFileManager to create a file at a path within a repository, but gives a 404.

e.g. with file_path="out/csv/Opportunity.csv"

      response = p.files.create({
                'file_path': file_path,
                'branch': args.branch,
                'content': file_content,
                'encoding': 'base64',
                'commit_message': args.commit_message
                })

Gives

https://gitlab.int.corefiling.com:443 "POST /api/v4/projects/922/repository/files/out/csv/Opportunity%2Ecsv HTTP/1.1" 404 25

Note that the . has been encoded as %2E, but the occurrences of / have not been encoded as %2F, which seems to be what the CRUD API requires (from experimentation with curl).

I'm using python-gitlab 1.0.2, which doesn't do anything fancy with the file_path:

https://github.com/python-gitlab/python-gitlab/blob/1.0.2/gitlab/v4/objects.py#L1434

If I pre-process file_path (file_path.replace("/", "%2F")), the call succeeds.

Is the / encoding meant to be the responsibility of the caller, or is this something that python-gitlab should take care of?

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

      0