500 error: java.io.IOException: Missing content for multipart request

1,904 views
Skip to first unread message

jru...@renewfinancial.com

unread,
Mar 22, 2018, 5:14:33 PM3/22/18
to wiremock-user
We started running into this problem with version 2.13, and everything works fine with older versions.  
Below is a simplified and scrubbed version of my request and mock. (In the real version, the POST includes a binary file and some additional headers)
I don't know if this is a bug in wiremock, a bug in jetty, a bug in my request, or something else.

Some related stuff I found:  
https://bugs.eclipse.org/bugs/show_bug.cgi?id=480063




Here's the contents of my mock file:
{
  "request": {
    "urlPathPattern": "/break_wiremock",
    "method": "POST"
  },
  "response": {
    "status": "200",
    "jsonBody": {
      "envelopeId": "passed-in-value-{{request.headers.X-return-value}}"
    },
    "transformers": ["response-template"],
    "headers": {
      "Content-Type": "application/json"
    }
  }
}

And here's the request I'm making:

POST /break_wiremock HTTP/1.1
Host: localhost:8443
X-return-value: something
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Cache-Control: no-cache
 
 
This is the error Wiremock is returning.  Nothing shows up in wiremock's logs:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Error 500 Server Error</title>
    </head>
    <body>
        <h2>HTTP ERROR 500</h2>
        <p>Problem accessing /break_wiremock. Reason:

            <pre>    Server Error</pre>
        </p>
        <h3>Caused by:</h3>
        <pre>java.io.IOException: Missing content for multipart request
at wiremock.org.eclipse.jetty.util.MultiPartInputStreamParser.parse(MultiPartInputStreamParser.java:491)
at wiremock.org.eclipse.jetty.util.MultiPartInputStreamParser.getParts(MultiPartInputStreamParser.java:400)
at wiremock.org.eclipse.jetty.server.Request.getParts(Request.java:2147)
at wiremock.org.eclipse.jetty.server.Request.getParts(Request.java:2099)
at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.getParts(WireMockHttpServletRequestAdapter.java:269)
at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:73)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:75)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:163)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:44)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at wiremock.org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
at wiremock.org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
at wiremock.org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:301)
at wiremock.org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499)
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
</pre>
        <hr>
        <i>
            <small>Powered by Jetty://</small>
        </i>
        <hr/>
    </body>
</html>

Tom Akehurst

unread,
Mar 23, 2018, 6:08:50 AM3/23/18
to wiremock-user
OK, so that looks like a Jetty bug (or poorly conceived feature, depending how you look at it). I guess it could be compensated for in WireMock by catching that particular exception and returning an empty Collection<Part>. Feel like raising a PR?

jru...@renewfinancial.com

unread,
Mar 23, 2018, 10:29:27 AM3/23/18
to wiremock-user
Unfortunately I don't know enough java to make that change.
Is there some other way I can help?

Tom Akehurst

unread,
Mar 23, 2018, 10:40:01 AM3/23/18
to wiremock-user
I'm planning to try and work on a batch of changes to WM over the next few days, so if you raise it as a bug in GitHub I might be able to get a fix out in the next release.

jru...@renewfinancial.com

unread,
Mar 23, 2018, 12:03:40 PM3/23/18
to wiremock-user
Done.  https://github.com/tomakehurst/wiremock/issues/909

Huge thanks for your help!
Message has been deleted

jru...@renewfinancial.com

unread,
Apr 11, 2018, 10:57:07 AM4/11/18
to wiremock-user

It appears that your fix only solved part of the problem.  When I use the mock from my initial post, I get a response as expected.
However, when I include a binary file in the body (I mentioned that my real test includes a binary file, but I can't provide it here, nor do I know enough about it to create a test version) I get the following error:


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Error 500 Server Error</title>
    </head>
    <body>
        <h2>HTTP ERROR 500</h2>
        <p>Problem accessing /restapi/v2/<token>/envelopes. Reason:

            <pre>    Server Error</pre>
        </p>
        <h3>Caused by:</h3>
        <pre>java.io.IOException: Missing content-disposition
at wiremock.org.eclipse.jetty.util.MultiPartInputStreamParser.parse(MultiPartInputStreamParser.java:555)

at wiremock.org.eclipse.jetty.util.MultiPartInputStreamParser.getParts(MultiPartInputStreamParser.java:400)
at wiremock.org.eclipse.jetty.server.Request.getParts(Request.java:2147)
at wiremock.org.eclipse.jetty.server.Request.getParts(Request.java:2099)
at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.safelyGetRequestParts(WireMockHttpServletRequestAdapter.java:280)
at com.github.tomakehurst.wiremock.servlet.WireMockHttpServletRequestAdapter.getParts(WireMockHttpServletRequestAdapter.java:264)
at com.github.tomakehurst.wiremock.verification.LoggedRequest.createFrom(LoggedRequest.java:63)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:74)

at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:163)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:50)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:44)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108)

Tom Akehurst

unread,
Apr 11, 2018, 10:58:56 AM4/11/18
to wiremock-user
Urgh. Would you mind popping that in a GitHub issue? Ideally with a test case or HTTP request I can use to replicate this particular error.

jru...@renewfinancial.com

unread,
Apr 11, 2018, 11:04:49 AM4/11/18
to wiremock-user
Sure thing.  I'll see if I can make a dummy version of the binary file first.

Tom Akehurst

unread,
Apr 11, 2018, 11:05:48 AM4/11/18
to wiremock-user
Thanks

jru...@renewfinancial.com

unread,
Apr 11, 2018, 11:35:40 AM4/11/18
to wiremock-user
Submitted:
https://github.com/tomakehurst/wiremock/issues/918

I'm not 100% sure about how well github's issue field liked the binary file contents I threw in there, so I've attached it here.

Thanks again,
Jason
binary_test

Tom Akehurst

unread,
Apr 11, 2018, 11:37:44 AM4/11/18
to wiremock-user
Thanks again. Will try and take a look in the next couple of days.
Reply all
Reply to author
Forward
0 new messages