-
Notifications
You must be signed in to change notification settings - Fork 669
Deleting a label fails with 404 #1867
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
Comments
Thanks @just-doit for the report, could you maybe add |
Hi, DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): <server>:443
send: b'GET /api/v4/user HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\n\r\n'
DEBUG:urllib3.connectionpool:https://<server>:443 "GET /api/v4/user HTTP/1.1" 200 None
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:20 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"ed942cb0878d870e37b48a0aeaebf227"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Request-Id: 01FTTVQ955Z8DCZA35GXEXMFR3
header: X-Runtime: 0.409683
header: Strict-Transport-Security: max-age=63072000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
send: b'GET /api/v4/projects/22 HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:21 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"9fe17adcff0c6b14ac0649f0cd33e9ba"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Request-Id: 01FTTVQ9WJAV0P68PMXBHP2RTQ
header: X-Runtime: 0.192599
header: Strict-Transport-Security: max-age=63072000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
send: b'GET /api/v4/projects/22/issues HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\n\r\n'
DEBUG:urllib3.connectionpool:https://<server>:443 "GET /api/v4/projects/22 HTTP/1.1" 200 None
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:21 GMT
header: Content-Type: application/json
header: Content-Length: 2
header: Connection: keep-alive
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
header: Link: <https://<server>/api/v4/projects/22/issues?id=22&order_by=created_at&page=1&per_page=20&sort=desc&state=all&with_labels_details=false>; rel="first", <https://<server>/api/v4/projects/22/issues?id=22&order_by=created_at&page=1&per_page=20&sort=desc&state=all&with_labels_details=false>; rel="last"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Next-Page:
header: X-Page: 1
header: X-Per-Page: 20
header: X-Prev-Page:
header: X-Request-Id: 01FTTVQA6ZGSY98Q9H8W5GW8EZ
header: X-Runtime: 0.054682
header: X-Total: 0
header: X-Total-Pages: 1
header: Strict-Transport-Security: max-age=63072000
header: Referrer-Policy: strict-origin-when-cross-origin
send: b'GET /api/v4/projects/22/labels HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\n\r\n'
DEBUG:urllib3.connectionpool:https://<server>:443 "GET /api/v4/projects/22/issues HTTP/1.1" 200 2
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:22 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"2cd7c4d6f8251fb7843d09ba9152f7fe"
header: Link: <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=2&per_page=20&with_counts=false>; rel="next", <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=1&per_page=20&with_counts=false>; rel="first", <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=2&per_page=20&with_counts=false>; rel="last"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Next-Page: 2
header: X-Page: 1
header: X-Per-Page: 20
header: X-Prev-Page:
header: X-Request-Id: 01FTTVQAKJ6F92YZYDN77N1V2G
header: X-Runtime: 0.156185
header: X-Total: 34
header: X-Total-Pages: 2
header: Strict-Transport-Security: max-age=63072000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
send: b'GET /api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=2&per_page=20&with_counts=false HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\n\r\n'
DEBUG:urllib3.connectionpool:https://<server>:443 "GET /api/v4/projects/22/labels HTTP/1.1" 200 None
reply: 'HTTP/1.1 200 OK\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:22 GMT
header: Content-Type: application/json
header: Transfer-Encoding: chunked
header: Connection: keep-alive
header: Vary: Accept-Encoding
header: Cache-Control: max-age=0, private, must-revalidate
header: Etag: W/"d990a9de7b074a273384e76d34afc9a5"
header: Link: <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=1&per_page=20&with_counts=false>; rel="prev", <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=1&per_page=20&with_counts=false>; rel="first", <https://<server>/api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=2&per_page=20&with_counts=false>; rel="last"
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Next-Page:
header: X-Page: 2
header: X-Per-Page: 20
header: X-Prev-Page: 1
header: X-Request-Id: 01FTTVQAXQ1MZD57G4FCXEDKT9
header: X-Runtime: 0.103709
header: X-Total: 34
header: X-Total-Pages: 2
header: Strict-Transport-Security: max-age=63072000
header: Referrer-Policy: strict-origin-when-cross-origin
header: Content-Encoding: gzip
send: b'DELETE /api/v4/projects/22/labels?name=comp%253AFlat%2520Export HTTP/1.1\r\nHost: <server>\r\nUser-Agent: python-gitlab/3.1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nPRIVATE-TOKEN: <secret>\r\nContent-type: application/json\r\nContent-Length: 0\r\n\r\n'
DEBUG:urllib3.connectionpool:https://<server>:443 "GET /api/v4/projects/22/labels?id=22&include_ancestor_groups=true&page=2&per_page=20&with_counts=false HTTP/1.1" 200 None
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Server: nginx
header: Date: Tue, 01 Feb 2022 14:41:22 GMT
header: Content-Type: application/json
header: Content-Length: 33
header: Connection: keep-alive
header: Cache-Control: no-cache
header: Vary: Origin
header: X-Content-Type-Options: nosniff
header: X-Frame-Options: SAMEORIGIN
header: X-Request-Id: 01FTTVQB4XQMSFJ74JY3YAA7KB
header: X-Runtime: 0.145771
DEBUG:urllib3.connectionpool:https://<server>:443 "DELETE /api/v4/projects/22/labels?name=comp%253AFlat%2520Export HTTP/1.1" 404 33
Traceback (most recent call last):
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/exceptions.py", line 311, in wrapped_f
return f(*args, **kwargs)
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/v4/objects/labels.py", line 183, in delete
self.gitlab.http_delete(self.path, query_data={"name": name}, **kwargs)
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/client.py", line 936, in http_delete
return self.http_request("delete", path, **kwargs)
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/client.py", line 727, in http_request
raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 404: 404 Label Not Found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/dirkmika/Library/Application Support/JetBrains/PyCharmCE2021.3/scratches/scratch_1.py", line 32, in <module>
gl_label.delete()
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/mixins.py", line 580, in delete
self.manager.delete(self.encoded_id, **kwargs)
File "/Users/dirkmika/Documents/projects/jira2gitlab/venv/lib/python3.9/site-packages/gitlab/exceptions.py", line 313, in wrapped_f
raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabDeleteError: 404: 404 Label Not Found
Process finished with exit code 1 |
Seems like this is wrong:
Probably should be:
But also we probably have multiple encoding happening.
|
@just-doit Any chance you can print the value of the label that you are trying to delete? |
It's |
The usage of deleting was incorrect according to the current API. Closes: #1867
The usage of deleting was incorrect according to the current API. Add tests to show it works with labels needing to be encoded. Also enable the test_group_labels() test function. Previously it was disabled. Closes: #1867
The usage of deleting was incorrect according to the current API. Remove custom `delete()` method as not needed. Add tests to show it works with labels needing to be encoded. Also enable the test_group_labels() test function. Previously it was disabled. Add ability to do a `get()` for group labels. Closes: #1867
I have proposed a fix here: #1868 |
The usage of deleting was incorrect according to the current API. Remove custom `delete()` method as not needed. Add tests to show it works with labels needing to be encoded. Also enable the test_group_labels() test function. Previously it was disabled. Add ability to do a `get()` for group labels. Closes: #1867
Wow this was fast. 👍 |
Description of the problem, including code/CLI snippet
I'm trying to delete all labels from a given project using this code:
The token works since I've used it successfully to do some other API calls before. The same user is able to delete labels manually via Web-UI.
Expected Behavior
I would expect the code not to throw a `gitlab.exceptions.GitlabDeleteError: 404: 404 Label Not Found'
Actual Behavior
The
delete
call fails with agitlab.exceptions.GitlabDeleteError: 404: 404 Label Not Found
.Specifications
The text was updated successfully, but these errors were encountered: