Import XAR - 400: Unable to parse form content

Summary: when trying to import a XAR file, I get a 400: Unable to parse form content error in the log.

Steps:
I downloaded the xwiki-platform-distribution-flavor-jetty-hsqldb-11.9 zip file.
Then changed the webapps\xwiki\WEB-INF\hibernate.cfg.xml file to point to MySQL.
Created the database and added permissions.
Started the wiki, created the admin user and installed the standard flavor.
Administer Wiki => Content => Export => generated a 127MB file.
Tried to import it and get the error.
I don’t get a stack trace, but only this in the request log:
0:0:0:0:0:0:0:1 - - [20/Nov/2019:07:20:43 +0000] “POST /xwiki/bin/get/XWiki/XWikiPreferences?xpage=packagedescriptor&package=xwikiBackup.xar HTTP/1.1” 200 464343
0:0:0:0:0:0:0:1 - - [20/Nov/2019:07:20:46 +0000] “GET /xwiki/webjars/wiki%3Axwiki/xwiki-platform-tree-webjar/11.9/tree.min.css?evaluate=true HTTP/1.1” 200 31686
0:0:0:0:0:0:0:1 - - [20/Nov/2019:07:20:54 +0000] “POST /xwiki/bin/import/XWiki/XWikiPreferences?editor=globaladmin&section=Import HTTP/1.1” 400 10130

and this in the output log:
2019-11-20 15:17:31.712:INFO:oejshC.xwiki:http://localhost:8080/xwiki/rest/notifications/count?media=json&userId=xwiki%3AXWiki.Admin&useUserPreferences=true&currentWiki=xwiki&async=true&_=1574234245030: RestletServlet: [Restlet] Attaching application: org.xwiki.rest.internal.XWikiRestletJaxRsApplication@70222514 to URI: /xwiki/rest
2019-11-20 15:20:54.012:WARN:oejs.HttpChannel:qtp1254526270-22: handleException /xwiki/bin/import/XWiki/XWikiPreferences org.eclipse.jetty.http.BadMessageException: 400: Unable to parse form content

Any way to find out why or what’s going on?

(Also, did a test on the xar file using 7zip and it says no errors)

is this an unsupported feature or are the steps incorrect in any way?

It is related to a configuration problem, you can find more information there: https://www.xwiki.org/xwiki/bin/view/FAQ/How%20to%20solve%20the%20"Unable%20to%20parse%20form%20content"%20error%20in%20Jetty

I tried it on the command line as well as in the jetty.xml but still get the same error.

Have you restarted your instance of XWiki after setting the configuration in jetty.xml?
Instead of:

<Call name="setAttribute">
    <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
    <Arg><Property name="jetty.maxFormContentSize" default="1000000"/></Arg>
  </Call>

maybe try:

  <Call name="setAttribute">
    <Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
    <Arg>1000000</Arg>
  </Call>

Might be proper way to set it now, according to the doc from https://www.eclipse.org/jetty/documentation/9.4.24.v20191120/setting-form-size.html

Tried that and still doesn’t work and yes, I did restart after each try.

I am just wondering how this setting could have any impact. The backup file is already uploaded so it should already be on the server. It’s when clicking the Import button that I get the 400 error.

The problem is not about the upload of the file, but of the pages you want to import. If I’m correct, you should have a list of pages to import in the UI, and basically when you chose to import all of them it creates a very big HTTP query with all the fields. It’s something we should fix in the future.

Now in your case, maybe there’s just again too many pages and 1000000 is not a value big enough.

As I mentioned in the first post, it’s a 127MB file. So I set it to 200MB.
Anyway, I was just testing out the export/import feature as a quick way to upgrade.
I guess I’ll use the DB backup approach instead. There seems to be auto db upgrades available.

Yeah it’s actually generally better to perform an XWiki upgrade.

So actually the issue is not related to maxFormContentSize but to maxFormKeys: it appears that the default value is limited to 1000 forms keys, which won’t be enough if you have more than 1000 pages. And by default XWiki 11.10 already have 1057 pages. You should be able to fix your problem by setting a new configuration in jetty.xml with a value of 2000 for maxFormKeys.