8000 gitlab project-commit create does not work with valid actions · Issue #3052 · python-gitlab/python-gitlab · GitHub
[go: up one dir, main page]

Skip to content
gitlab project-commit create does not work with valid actions #3052
Open
@Anthony-Fiddes

Description

@Anthony-Fiddes

Description of the problem, including code/CLI snippet

It appears that the CLI may be passing the actions flag as a string instead of as JSON. I saw this 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): *************:443
DEBUG: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: nginx
DEBUG:http.client:header: Date: Fri, 29 Nov 2024 16:18:55 GMT
DEBUG:http.client:header: Content-Type: application/json
DEBUG:http.client:header: Transfer-Encoding: chunked
DEBUG:http.client:header: Connection: keep-alive
DEBUG:http.client:header: Vary: Accept-Encoding
DEBUG:http.client:header: Cache-Control: max-age=0, private, must-revalidate
DEBUG:http.client:header: Vary: Origin
DEBUG:http.client:header: X-Content-Type-Options: nosniff
DEBUG:http.client:header: X-Frame-Options: SAMEORIGIN
DEBUG: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-origin
DEBUG:http.client:header: Content-Encoding: gzip
DEBUG:urllib3.connectionpool:https://*************:443 "GET /api/v4/user HTTP/11" 200 None
DEBUG:http.client:send: b'POST /api/v4/******/repository/commits
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\nContent-Length: 368\r\nAuthorization: Bearer [MASKED]\r\n\r\n'

LINE OF POTENTIAL INTEREST
vvvvvvvvvvvvvvvvvvvvvvvvvvv
DEBUG: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: nginx
DEBUG:http.client:header: Date: Fri, 29 Nov 2024 16:18:55 GMT
DEBUG:http.client:header: Content-Type: application/json
DEBUG:http.client:header: Content-Length: 30
DEBUG:http.client:header: Connection: keep-alive
DEBUG:http.client:header: Cache-Control: no-cache
DEBUG:http.client:header: Vary: Origin
DEBUG:http.client:header: X-Content-Type-Options: nosniff
DEBUG:http.client:header: X-Frame-Options: SAMEORIGIN
DEBUG: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 30
Impossible 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):

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