1

There's a bulk import feature in a Grails 2.4.3 app I'm working on, the last stage of which is a table where every cell has an input. I'm submitting this all via a tag.

I've noticed that when the table is large enough to have more than 10,002 params, some data is missing from the params. I noticed this due to failed validation in some of the saved domains (due to missing required fields), then determined this maximum number by printing

params.keySet().size() // always 10,002

Just as a sanity check I created a Groovy map with 20k entries, so this isn't a language-level constraint. The params include controller and action, so it looks like it comes to a nice round 10k for user-defined params. Is this a known limit? If so, is it configurable?

Sitati
  • 285
  • 3
  • 13
  • Are these all going in a GET request via the URL? If so: http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers – tim_yates Jul 29 '15 at 11:48
  • @tim_yates - I think the answer to your question may be "no", but I can't be sure. He/she posted the same question on the mailing list and there indicated that these might be form parameters. – Jeff Scott Brown Jul 29 '15 at 13:35
  • @tim_yates these are form parameters being POSTed. As JSB mentioned, I posted this on the mailing list and got a reply from him, that discussion is here: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/grails-dev-discuss/L2F-0wKyQrU – Sitati Jul 29 '15 at 13:50

1 Answers1

2

You have exceeded Tomcat's default maximum parameter count. Note that this situation is detectable (see the documentation link below).

See http://tomcat.apache.org/tomcat-8.0-doc/config/http.html, search for maxParameterCount.

You can trivially set the value higher if you'd like.

Odd that you are seeing 10002 and not 10000.

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77
  • The 10,002 includes 'controller' and 'action', which aren't actually submitted from the form but injected into the params object by the framework. Could you explain how to change this? I tried adding `maxParameterCount="20000"` to the http connector config in server.xml but it had no effect. – Sitati Aug 03 '15 at 11:44
  • What version of Tomcat are you using? – Christopher Schultz Aug 07 '15 at 21:12
  • We're on Tomcat 7.0.42 – Sitati Aug 09 '15 at 09:23
  • Please give it a try with Tomcat 7.0.latest, currently 7.0.63. – Christopher Schultz Aug 12 '15 at 13:11
  • 1
    You were right, it was Tomcat's maxParameterCount kicking in. Tomcat will just silently ignore the x+1st param and every other after it. The fix was to add our own value on the Connector attribute in Tomcat's server.xml `` When choosing a value for this, it is worth bearing in mind that one motivation for this limit is to mitigate DOS attacks: http://stackoverflow.com/a/12277296 – Sitati Aug 26 '15 at 08:19
  • It certainly doesn't do it silently: it will set an attribute on the request that you can check. But you are right: it won't return a 400 response or anything like that. 10k parameters is a *lot* of parameters. – Christopher Schultz Aug 26 '15 at 21:17
  • I don't have server.xml but web.xml, how can I set MAX_COUNT in my Grails project? – Asif Jun 01 '21 at 06:14
  • @Asif In order to change this particular configuration setting, you need to modify the server's configuration. You cannot do this through the application itself, through `web.xml`. If your Grails project only builds a WAR file (or similar), then you will need to talk to your administrator about changing this at the server-level. – Christopher Schultz Jun 01 '21 at 16:07