question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pact server fails for requests that don't have Content-Type header

See original GitHub issue

I tried to update my current pact-jvm-server from 3.6.1 to 4.0.4, but for GET requests it fails with 500. Looking in the stacktrace I see there is a problem at au.com.dius.pact.server.Conversions.unfilteredRequestToPactRequest. This method reads Content-Type header for all types of requests. I think a better way is to check if this header exists and if it is missing use some default values like text/plain with charset UTF-8.

Below is the stacktrace from pact-jvm-server:4.0.4:

java.util.NoSuchElementException
	at java.util.AbstractList$Itr.next(AbstractList.java:364)
	at scala.collection.convert.Wrappers$JIteratorWrapper.next(Wrappers.scala:40)
	at au.com.dius.pact.server.Conversions$.unfilteredRequestToPactRequest(Conversions.scala:53)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$.convertRequest(UnfilteredMockProvider.scala:27)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$$anonfun$intent$1.applyOrElse(UnfilteredMockProvider.scala:24)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$$anonfun$intent$1.applyOrElse(UnfilteredMockProvider.scala:23)
	at scala.PartialFunction$Lifted.apply(PartialFunction.scala:224)
	at scala.PartialFunction$Lifted.apply(PartialFunction.scala:220)
	at unfiltered.response.Pass$PartialAttempt.attemptWithPass(pass.scala:72)
	at unfiltered.response.Pass$PassingAttempt.attempt(pass.scala:65)
	at unfiltered.response.Pass$PassingAttempt.attempt$(pass.scala:65)
	at unfiltered.response.Pass$PartialAttempt.attempt(pass.scala:67)
	at unfiltered.response.Pass$.$anonfun$fold$1(pass.scala:48)
	at unfiltered.response.Pass$FunctionAttempt.apply(pass.scala:77)
	at unfiltered.netty.cycle.Plan.$anonfun$channelRead$3(plans.scala:68)
	at unfiltered.netty.cycle.Plan.catching(plans.scala:41)
	at unfiltered.netty.cycle.Plan.catching$(plans.scala:40)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$.catching(UnfilteredMockProvider.scala:19)
	at unfiltered.netty.cycle.Plan.$anonfun$channelRead$2(plans.scala:67)
	at unfiltered.netty.cycle.SynchronousExecution.executeIntent(deferrals.scala:23)
	at unfiltered.netty.cycle.SynchronousExecution.executeIntent$(deferrals.scala:23)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$.executeIntent(UnfilteredMockProvider.scala:19)
	at unfiltered.netty.cycle.Plan.$anonfun$channelRead$1(plans.scala:66)
	at unfiltered.netty.cycle.Plan.catching(plans.scala:41)
	at unfiltered.netty.cycle.Plan.catching$(plans.scala:40)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$.catching(UnfilteredMockProvider.scala:19)
	at unfiltered.netty.cycle.Plan.channelRead(plans.scala:65)
	at unfiltered.netty.cycle.Plan.channelRead$(plans.scala:61)
	at au.com.dius.pact.server.UnfilteredMockProvider$Routes$.channelRead(UnfilteredMockProvider.scala:19)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:321)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:295)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1408)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:930)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:697)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:632)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:549)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:511)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
uglyogcommented, Feb 22, 2020

Done

0reactions
uglyogcommented, Mar 8, 2020

version 4.0.7 has been released

Read more comments on GitHub >

github_iconTop Results From Across the Web

Pact server fails for requests that don't have Content-Type ...
Pact server fails for requests that don't have Content-Type header # ... This method reads Content-Type header for all types of requests.
Read more >
Pact Request and Response Matching | Pact Docs
This library implements the core matching logic required for matching HTTP requests and responses. It is based on the.
Read more >
pact_verifier_cli — Rust application // Lib.rs
Standalone pact verifier for provider pact verification | Rust/Cargo package. ... which has status code 200 (FAILED) includes headers "Content-Type" with ...
Read more >
spring - How to add a header for a pact provider test using ...
1.1) header: Expected a header 'Content-Type' but was missing. This message comes from the response validation on the provider side.
Read more >
@pact-foundation/pact - npm
Start using @pact-foundation/pact in your project by running `npm i ... the server and client side, in which case, these tests don't need...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found