com.github.tomakehurst.wiremock.common.JsonException: {
"errors" : [ {
"code" : 10,
"source" : { },
"title" : "Error parsing JSON",
"detail" : "Unrecognized token 'x': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"x��R]k�0\u0010�+Eϲ...\"; line: 1, column: 2]"
} ]
}
at com.github.tomakehurst.wiremock.common.JsonException.fromJackson(JsonException.java:53)
at com.github.tomakehurst.wiremock.common.Json.read(Json.java:55)
at com.github.tomakehurst.wiremock.matching.EqualToJsonPattern.<init>(EqualToJsonPattern.java:24)
at com.github.tomakehurst.wiremock.recording.RequestBodyAutomaticPatternFactory.forRequest(RequestBodyAutomaticPatternFactory.java:68)
at com.github.tomakehurst.wiremock.recording.RequestPatternTransformer.apply(RequestPatternTransformer.java:60)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingGenerator.apply(SnapshotStubMappingGenerator.java:52)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingGenerator.apply(SnapshotStubMappingGenerator.java:31)
at com.google.common.collect.Iterators$6.transform(Iterators.java:783)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingPostProcessor.process(SnapshotStubMappingPostProcessor.java:55)
at com.github.tomakehurst.wiremock.recording.Recorder.serveEventsToStubMappings(Recorder.java:132)
at com.github.tomakehurst.wiremock.recording.Recorder.takeSnapshot(Recorder.java:105)
at com.github.tomakehurst.wiremock.core.WireMockApp.snapshotRecord(WireMockApp.java:446)
at com.github.tomakehurst.wiremock.core.WireMockApp.snapshotRecord(WireMockApp.java:442)
at com.github.tomakehurst.wiremock.WireMockServer.snapshotRecord(WireMockServer.java:461)
at app.transformer.RecordMocks.transform(RecordMocks.kt:49)
at app.transformer.RequestTransformer.transform(RequestTransformer.kt:38)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:101)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:80)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:209)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:56)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:64)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:121)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:383)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
at java.lang.Thread.run(Thread.java:748)
com.github.tomakehurst.wiremock.common.JsonException: {
"errors" : [ {
"code" : 10,
"source" : { },
"title" : "Error parsing JSON",
"detail" : "Unrecognized token 'x': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"x�u��J�0\u0010�_Er�C�$MһEŽQ\u0004ћR�ئk�m�4]<�wwZW\u0014�!���\u0017&�\t�\\\u0010!��)�P�JR\u00049����M�\u0002D\b\\�͛i/(x'a�7���G��08u�(.��\u001BY���*T%��.9ǵQ\\�%�}ۍ��֠�\u0013\r͇A\u0019��t\u000Bʡվ�\u0000��o���ۓqCc{�NS�\"�\u0011\u000Er\u0000ΡUi\u000Fs/��u7{\u000Ff�\u000B��A/��`biG �H���03\u0013\u0011V\u0012�a�+�S�\u0003�5�\u0019A��\u000B���l�\u001B^G�̀2�#*I���T)&8��Bޚκ��q0�:����i�C�'�Y~��\u0004R\u0012\t\fT�%�����p����m�{�,vkt�_�K۶����[�f�뀰�$���4e�HLO�g�\u0019|]���4\u0012KR\u0002�`J��ME��|��\t��\u000B���k\"; line: 1, column: 2]"
} ]
}
at com.github.tomakehurst.wiremock.common.JsonException.fromJackson(JsonException.java:53)
at com.github.tomakehurst.wiremock.common.Json.read(Json.java:55)
at com.github.tomakehurst.wiremock.matching.EqualToJsonPattern.<init>(EqualToJsonPattern.java:24)
at com.github.tomakehurst.wiremock.recording.RequestBodyAutomaticPatternFactory.forRequest(RequestBodyAutomaticPatternFactory.java:68)
at com.github.tomakehurst.wiremock.recording.RequestPatternTransformer.apply(RequestPatternTransformer.java:60)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingGenerator.apply(SnapshotStubMappingGenerator.java:52)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingGenerator.apply(SnapshotStubMappingGenerator.java:31)
at com.google.common.collect.Iterators$6.transform(Iterators.java:783)
at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:47)
at com.github.tomakehurst.wiremock.recording.SnapshotStubMappingPostProcessor.process(SnapshotStubMappingPostProcessor.java:55)
at com.github.tomakehurst.wiremock.recording.Recorder.serveEventsToStubMappings(Recorder.java:132)
at com.github.tomakehurst.wiremock.recording.Recorder.takeSnapshot(Recorder.java:105)
at com.github.tomakehurst.wiremock.core.WireMockApp.snapshotRecord(WireMockApp.java:446)
at com.github.tomakehurst.wiremock.core.WireMockApp.snapshotRecord(WireMockApp.java:442)
at com.github.tomakehurst.wiremock.WireMockServer.snapshotRecord(WireMockServer.java:461)
at app.transformer.RecordMocks.transform(RecordMocks.kt:49)
at app.transformer.RequestTransformer.transform(RequestTransformer.kt:38)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.applyTransformations(InMemoryStubMappings.java:101)
at com.github.tomakehurst.wiremock.stubbing.InMemoryStubMappings.serveFor(InMemoryStubMappings.java:80)
at com.github.tomakehurst.wiremock.core.WireMockApp.serveStubFor(WireMockApp.java:209)
at com.github.tomakehurst.wiremock.http.StubRequestHandler.handleRequest(StubRequestHandler.java:56)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:64)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:121)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
I imagine the bug could be replicated by having an "ugly/undesirable" response body like the above "x�u��J�0\u0010�_Er�C�$MһEŽQ\u0004ћR�ئk�m�4]<�wwZW\u0014�!���\u0017&�\t�\\\u0010!��)�P�JR\u00049����M�\u0002D\b\\�͛i/(x'a�7���G��08u�(.��\u001BY���*T%��.9ǵQ\\�%�}ۍ��֠�\u0013\r͇A\u0019��t\u000Bʡվ�\u0000��o���ۓqCc{�NS�\"�\u0011\u000Er\u0000ΡUi\u000Fs/��u7{\u000Ff�\u000B��A/��`biG �H���03\u0013\u0011V\u0012�a�+�S�\u0003�5�\u0019A��\u000B���l�\u001B^G�̀2�#*I���T)&8��Bޚκ��q0�:����i�C�'�Y~��\u0004R\u0012\t\fT�%�����p����m�{�,vkt�_�K۶����[�f�뀰�$���4e�HLO�g�\u0019|]���4\u0012KR\u0002�`J��ME��|��\t��\u000B���k\" going through the SnapshotStubMappingGenerator. We are proxying to WireMock from an Android mobile application, I believe this response is part of some obfuscated NewRelic tracking data, and not something we want to record a StubMapping for. It may be nice to have this JsonException caught and get back a StubMapping with an empty body or some signifier that it failed to build a StubMapping.
We're using WireMock jre8 in browser proxy mode as part of a Maven executable running in a Docker container, with our app proxying to the WireMock instance. Recording/replaying of our traffic on the hosts we need to record is working fantastically, it's just the "extra" traffic that ends up going through the browser proxy that we'd love to avoid or have the errors swallowed silently.
Let me know if any additional information is needed! Really appreciate you looking into these bugs
Nikolas