[go: up one dir, main page]

Commit with file fails when form encoding is used

Summary

When trying to do a commit that uploads a file using form encoding, the upload fails with "Bad Request", when the size of the payload is bigger then 11 MB (12582912 bytes, Content-Length: 16998844 fails).

The failed request is seen in nginx access logs and also gitlab-workhorse logs.

gitlab-workhorse/current:{"backend_id":"rails","body_limit":104857600,"content_type":"text/plain","correlation_id":"01KB2J3APZZ3RGGKWB679RWQBZ","duration_ms":366,"host":"gitlab.example.com","level":"info","method":"POST","msg":"access","proto":"HTTP/1.1","read_bytes":41500286,"referrer":"","remote_addr":"127.0.0.1:0","remote_ip":"1.2.3.4","route":"^/api/","route_id":"api","status":400,"system":"http","time":"2025-11-27T12:45:09+01:00","ttfb_ms":366,"uri":"/api/v4/projects/1234/repository/commits","user_agent":"curl/8.11.1","written_bytes":11}

There are no futher logs to a given correlation id, e.g. in rails log.

Steps to reproduce

The file uploaded in the commit needs to be bigger then 11 MB.

curl --form "branch=main" --form "commit_message=commitmsg" --form "start_branch=main" --form "actions[][action]=create" --form "actions[][file_path]=TEST12mb.txt" --form "actions[][content]=<$filename" --form "actions[][encoding]=base64" --header "PRIVATE-TOKEN: glpat-" "https://gitlab.example.com/api/v4/projects/1234/repository/commits" --verbose --show-error --fail-with-body

< HTTP/1.1 400 Bad Request
< Content-Type: text/plain
< Content-Length: 11
< Connection: keep-alive
< Server: nginx
...

It works with files bigger then 11 MB when json encoding is used.

curl --request POST "https://gitlab.example.com/api/v4/projects/1234/repository/commits" --header "PRIVATE-TOKEN: glpat-" --header "Content-Type: application/json" --data @- << EOF
{
  "branch": "main",
  "start_branch": "main",
  "commit_message": "commitmsg",
  "actions": [
    {
      "action": "create",
      "file_path": "TEST12mb.txt",
      "encoding": "base64",
      "content": "$BASE64_CONTENT"
    }
  ]
}
EOF

What is the current bug behavior?

Upload of files bigger then 11 MB fails with bad request.

What is the expected correct behavior?

Form encoding and json works the same, as documented here.

https://docs.gitlab.com/api/commits/#create-a-commit-with-multiple-files-and-actions

Results of GitLab environment info

Issue can be reproduced with latest GitLab-EE Omnibus Installation e.g. 18.6.1.

Edited by 🤖 GitLab Bot 🤖