Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

RFE: We should catch all 301, 302 redirects #1485

Copy link
Copy link
@JohnVillalovos

Description

@JohnVillalovos
Issue body actions

Currently we raise an error if there is a 301, 302 redirect from an http URL to an httpS URL for any non GET methods.

But we don't raise an error for any other redirects.

This causes two problems:

  1. PUT requests that are redirected get changed to GET requests which don't perform the correct action but raise no error. This is because the GET response succeeds but since it wasn't a PUT it doesn't update. This can be seen by updating a user status. It raises no errors but the status does not change. See issue Changing milestone of issue does not work #1432
  2. POST requests blow up with hard to debug tracebacks. See below. Also see issue Not possible to create note in issue #1477

An example of attempting to upload an SSH key on a URL that redirects with 302 for the POST request:

Traceback (most recent call last):
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/base.py", line 77, in __getattr__
    return self.__dict__["_updated_attrs"][name]
KeyError: '_managers'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jlvillal/sources/local/py-gitlab-testing/./tt.py", line 109, in <module>
    sys.exit(main())
  File "/home/jlvillal/sources/local/py-gitlab-testing/./tt.py", line 82, in main
    k = user.keys.create({"title": "My key", "key": SSH_KEY})
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/exceptions.py", line 287, in wrapped_f
    return f(*args, **kwargs)
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/mixins.py", line 325, in create
    return self._obj_cls(self, server_data)
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/base.py", line 62, in __init__
    self._create_managers()
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/base.py", line 145, in _create_managers
    managers = getattr(self, "_managers", None)
  File "/home/jlvillal/.local/lib/python3.9/site-packages/gitlab/base.py", line 80, in __getattr__
    value = self.__dict__["_attrs"][name]
TypeError: list indices must be integers or slices, not str

Metadata

Metadata

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

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.