pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 480 forks source link

warning messages for application/x-thrift #1314

Open iankurrathi opened 3 years ago

iankurrathi commented 3 years ago

After implementing fix for https://github.com/pact-foundation/pact-jvm/issues/1298, we are noticing warning messages in logs in producer tests.

we are using 4.1.17 version and using system override property to treat application/x-thrift as json:

System.setProperty("pact.content_type.override.application/x-thrift", "json");

we are going to raise a PR to fix this issue.

24 Feb 2021 08:01:44,078 WARN HttpPart:80 [main] Expected body for content type application/x-thrift to be base64 encoded java.lang.IllegalArgumentException: Illegal base64 character 5b at java.base/java.util.Base64$Decoder.decode0(Base64.java:743) ~[?:?] at java.base/java.util.Base64$Decoder.decode(Base64.java:535) ~[?:?] at java.base/java.util.Base64$Decoder.decode(Base64.java:558) ~[?:?] at au.com.dius.pact.core.model.HttpPart$Companion.decodeBody(HttpPart.kt:78) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.HttpPart$Companion.extractBody(HttpPart.kt:70) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.Request$Companion.fromJson(Request.kt:125) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.DefaultPactReader.extractRequest(PactReader.kt:291) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.DefaultPactReader$loadV3Pact$interactions$1.invoke(PactReader.kt:242) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.DefaultPactReader$loadV3Pact$interactions$1.invoke(PactReader.kt:186) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.support.json.JsonValueKt.map(JsonValue.kt:263) ~[support-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.DefaultPactReader.loadV3Pact(PactReader.kt:241) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.core.model.DefaultPactReader.loadPact(PactReader.kt:200) ~[model-4.1.17.jar:4.1.17] at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:227) ~[provider-4.1.17.jar:4.1.17] at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:111) ~[provider-4.1.17.jar:4.1.17]

uglyog commented 3 years ago

This looks like an inconsistency in the implementation. The values for pact.content_type.override.* should be text or binary. You are setting it to json, so it should not be treated as a binary format, but it is. I'm not sure why, but I'm going to change it to make json a valid value for that property.

uglyog commented 3 years ago

The reason for treating it as a binary content type is the slash in the property key. It was looking for pact.content_type.override.application.x-thrift not pact.content_type.override.application/x-thrift. I'm going to fix it to accept both.

uglyog commented 3 years ago

4.1.18 released