GitLab APIv3: 414 Request URI Too Long

I’m coming across this error when I’m creating notes in GitLab where I’m inserting markup table content as a comment on an Issue. My current work around is to split a larger table up into multiple comments.

To create the note, I’m passing the body as a URL parameter. The markdown text for tables that is URL-encoded gets long pretty quickly without having a lot of content. Anyhow, because the data is submitted as a URL parameter, I’m getting 414 errors from my local GitLab CE instance. I’m looking into configuring Nginx to allow larger URI’s, but that isn’t a real solution.

As a shot in the dark, I tried sending the body text as JSON in the POST request body, but that doesn’t work.

{ "body":"| Column 1 | Column 2 | etc. etc." }

Is there another way I can add long comments to an issue?

Thanks in advance,

–Paul

####UPDATE 2016.08.17-13:51:51
I added the following line to /var/opt/gitlab/nginx/conf/gitlab-http.conf:

large_client_header_buffers 4 16k;

It seems to do the trick for me for the time being. I didn’t see an option in /etc/gitlab/gitlab.rb for this setting, so I’ll likely need to make it again next time I reconfigure.

####UPDATE 2016.08.17-14:06:55
I changed the buffer setting in /var/opt/gitlab/nginx/conf/gitlab-http.conf to:

large_client_header_buffers 8 32k;

With further testing, I unfortunately still get the 414 error, so I still need to split my table into multiple notes.

There is an option to add arbitrary Nginx configuration in gitlab.rb that will be added to the Nginx config when you run reconfigure. I don’t have it in front of me at the moment, but it shouldn’t be too hard to find.

This rare condition is only likely to occur when a client has improperly converted a POST request to a GET request with long query information. The HTTP 414 URI Too Long response status code indicates that the URI(Uniform Resource Identifier) requested by the client is longer than the server is willing to interpret.

To resolve this problem :

  • By POST request: Convert query string to json object and sent to API request with POST.

  • By GET request: Max length of request is depend on sever side as well as client side. Most webserver have limit 8k which is configurable. On the client side the different browser has different limit. The browser IE and Safari limit to 2k, Opera 4k and Firefox 8k. This means that the max length for the GET request is 8k and min request length is 2k.

If exceed the request max length then the request truncated outside the limit by web server or browser without any warning. Some server truncated request data but the some server reject it because of data lose and they will return with response code 414 Request-URI Too Long.

Under Apache, the limit is a configurable value, LimitRequestLine. If you want to increase URL limit to 5000 characters (bytes), add the following lines to your server configuration or virtual host file.

LimitRequestLine 5000

If you want to increase maximum header length supported by Apache to 3000 characters, then add the following line.

LimitRequestFieldSize 3000