Visitar URL original
project.wikis.create with subpages results in 404 Wiki Page Not Found · Issue #1079 · python-gitlab/python-gitlab · GitHub
Skip to content

project.wikis.create with subpages results in 404 Wiki Page Not Found #1079

Description

@kernelport

Description of the problem, including code/CLI snippet

page = project.wikis.create({'title': "title/subtitle", 'content': "test content"})
does create a wiki subtitle in the directory title well.
If I try to edit this page with:
page.content = "update content"
page.title = "subtitle" # Attention: during update the page we have to set the title without the directory name
page.save()
I get gitlab.exceptions.GitlabUpdateError: 404: 404 Wiki Page Not Found

I can reproduce this by using curl:

curl --request PUT --data "content=update content" --header "PRIVATE-TOKEN: XXX" https://gitlab.kernelport.com/api/v4/projects/231/wikis/title/subtitle

But when I encode the slug URL it does work with curl.

curl --request PUT --data "content=update content" --header "PRIVATE-TOKEN: XXX" https://gitlab.kernelport.com/api/v4/projects/231/wikis/title%2Fsubtitle

How can I handle this URL Encoding for slug in python-gitlab correct?

Expected Behavior

Actual Behavior

Specifications

  • python-gitlab version: 2.0.1
  • API version you are using (v3/v4): V4
  • Gitlab server version (or gitlab.com): '12.8.1', 'd18b43a5f5a'

Activity

  1. justinTM commented on Sep 8, 2021

    @justinTM

    @kernelport I think I can replicate your url encoding fix as well.

    this works:

    page = wiki.project.wikis.get('my/path/to/asdasd')
    >>> page.save()
    >>> page.slug
    'my/path/to/asdasd'
    >>> page.slug = 'my%2Fpath%2Fto%2Fasdasd'
    >>> page.save()
    >>> 

    but this will 404 error:

    >>> page.slug = 'my%2Fpath%2Fto/asdasd'
    >>> page.save()
    Traceback (most recent call last):
      File "/Library/Python/3.8/site-packages/gitlab/exceptions.py", line 304, in wrapped_f
        return f(*args, **kwargs)
      File "/Library/Python/3.8/site-packages/gitlab/mixins.py", line 417, in update
        result = http_method(path, post_data=new_data, files=files, **kwargs)
      File "/Library/Python/3.8/site-packages/gitlab/client.py", line 807, in http_put
        result = self.http_request(
      File "/Library/Python/3.8/site-packages/gitlab/client.py", line 628, in http_request
        raise gitlab.exceptions.GitlabHttpError(
    gitlab.exceptions.GitlabHttpError: 404: 404 Not Found
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Library/Python/3.8/site-packages/gitlab/mixins.py", line 552, in save
        server_data = self.manager.update(obj_id, updated_data, **kwargs)
      File "/Library/Python/3.8/site-packages/gitlab/exceptions.py", line 306, in wrapped_f
        raise error(e.error_message, e.response_code, e.response_body) from e
    gitlab.exceptions.GitlabUpdateError: 404: 404 Not Found
    >>> 
  2. added 14 commits that reference this issue on Jan 9, 2022
    211d461
    535636f
    720c11a
    598aa08
    37dff7e
    fd8a747
    1df929c
    99e1f8b
    9b40dda
    54abe80
    e6ba4b2
    5167c47
    6dea32a
    12435d7
  3. locked as resolved and limited conversation to collaborators on Jan 16, 2023
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions