- Notifications
You must be signed in to change notification settings - Fork673
Description
Description of the problem, including code/CLI snippet
It appears that the CLI may be passing theactions
flag as a string instead of as JSON. I sawthis potentially related discussion (it's an old discussion, so it may be out of date), but I couldn't find a corresponding issue.
Command run:gitlab -d project-commit create --project-id ****** --branch main --commit-message 'create multiple/' --actions '[{"action": "create", "file_path": "multiple/file-to-commit1.txt", "content": "@multiple/file-to-commit1.txt"}, {"action": "create", "file_path": "multiple/file-to-commit2.txt", "content": "@multiple/file-to-commit2.txt"}, {"action": "create", "file_path": "multiple/file-to-commit3.txt", "content": "@multiple/file-to-commit3.txt"}]'
Output:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): *************:443DEBUG:http.client:send: b'GET /api/v4/user HTTP/1.1\r\nHost: *************\r\nUser-Agent: *********************\r\nAccept-Encoding: gzip, deflate\r\nAccept: _/_\r\nConnection: keep-alive\r\nContent-type: application/json\r\nAuthorization: Bearer [MASKED]\r\n\r\n'DEBUG:http.client:reply: 'HTTP/1.1 200 OK\r\n'DEBUG:http.client:header: Server: nginxDEBUG:http.client:header: Date: Fri, 29 Nov 2024 16:18:55 GMTDEBUG:http.client:header: Content-Type: application/jsonDEBUG:http.client:header: Transfer-Encoding: chunkedDEBUG:http.client:header: Connection: keep-aliveDEBUG:http.client:header: Vary: Accept-EncodingDEBUG:http.client:header: Cache-Control: max-age=0, private, must-revalidateDEBUG:http.client:header: Vary: OriginDEBUG:http.client:header: X-Content-Type-Options: nosniffDEBUG:http.client:header: X-Frame-Options: SAMEORIGINDEBUG:http.client:header: X-Gitlab-Meta: {"correlation*id":"***********","version":"1"}DEBUG:http.client:header: X-Request-Id: ***************DEBUG:http.client:header: Referrer-Policy: strict-origin-when-cross-originDEBUG:http.client:header: Content-Encoding: gzipDEBUG:urllib3.connectionpool:https://*************:443 "GET /api/v4/user HTTP/11" 200 NoneDEBUG:http.client:send: b'POST /api/v4/******/repository/commitsHTTP/1.1\r\nHost: *************\r\nUser-Agent: **********\r\nAccept-Encoding: gzip, deflate\r\nAccept: */\_\r\nConnection: keep-alive\r\nContent-type: application/json\r\nContent-Length: 368\r\nAuthorization: Bearer [MASKED]\r\n\r\n'LINE OF POTENTIAL INTERESTvvvvvvvvvvvvvvvvvvvvvvvvvvvDEBUG:http.client:send: b'{"branch": "main", "commit_message": "create multiple/", "actions": "[{action: create, file_path: multiple/file-to-commit1.txt, content: @multiple/file-to-commit1.txt}, {action: create, file_path: multiple/file-to-commit2.txt, content: @multiple/file-to-commit2.txt}, {action: create, file_path: multiple/file-to-commit3.txt, content: @multiple/file-to-commit3.txt}]"}'DEBUG:http.client:reply: 'HTTP/1.1 400 Bad Request\r\n'DEBUG:http.client:header: Server: nginxDEBUG:http.client:header: Date: Fri, 29 Nov 2024 16:18:55 GMTDEBUG:http.client:header: Content-Type: application/jsonDEBUG:http.client:header: Content-Length: 30DEBUG:http.client:header: Connection: keep-aliveDEBUG:http.client:header: Cache-Control: no-cacheDEBUG:http.client:header: Vary: OriginDEBUG:http.client:header: X-Content-Type-Options: nosniffDEBUG:http.client:header: X-Frame-Options: SAMEORIGINDEBUG:http.client:header: X-Gitlab-Meta: {"correlation_id":"***************","version":"1"}DEBUG:http.client:header: X-Request-Id: ***************DEBUG:urllib3.connectionpool:https://*************:443 "POST /api/v4/******/repository/commits HTTP/11" 400 30Impossible to create object (400: actions is invalid)
Expected Behavior
Create a new commit in the repo with the new files.
Actual Behavior
Fails with a 400 error saying "actions is invalid" (and it's possible I could be missing something here. I checked that my JSON was valid and checked with the official Gitlab API spec as first steps in debugging).
Specifications
- python-gitlab version: 5.0.0
- Gitlab server version (or gitlab.com):