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.
We found an odd issue with the pact jvm consumer dependency update, from version 4.6.5 and up, specifically with query matchers. One provider we use has queries that have square brackets [] in them, i.e. principle_identifier[account_id] etc. When running pact tests to generate a contract, running individual test classes runs fine, but as soon as another test class is added to run together, the second class throws errors, seemingly treating the brackets in the query key as an array:
[ERROR] GetAuthorizationContractTest -- Time elapsed: 0.919 s <<< ERROR!
au.com.dius.pact.core.model.InvalidPathExpression: Indexes can only consist of numbers or a "*", found "a" instead in path expression "$.query.principal_identifier[account_id]" at index 29
at au.com.dius.pact.core.model.PathExpressionsKt.bracketPath(PathExpressions.kt:141)
at au.com.dius.pact.core.model.PathExpressionsKt.pathExp(PathExpressions.kt:165)
at au.com.dius.pact.core.model.PathExpressionsKt.parsePath(PathExpressions.kt:181)
at au.com.dius.pact.core.model.matchingrules.MatchingRulesImpl.fromV2Json(MatchingRulesImpl.kt:34)
at au.com.dius.pact.core.model.matchingrules.MatchingRulesImpl$Companion.fromJson(MatchingRulesImpl.kt:104)
at au.com.dius.pact.core.model.Request$Companion.fromJson(Request.kt:170)
at au.com.dius.pact.core.model.DefaultPactReader.extractRequest(PactReader.kt:327)
at au.com.dius.pact.core.model.DefaultPactReader$loadV2Pact$interactions$1.invoke(PactReader.kt:283)
at au.com.dius.pact.core.model.DefaultPactReader$loadV2Pact$interactions$1.invoke(PactReader.kt:282)
at au.com.dius.pact.core.support.json.JsonValueKt.map(JsonValue.kt:338)
at au.com.dius.pact.core.model.DefaultPactReader.loadV2Pact(PactReader.kt:282)
at au.com.dius.pact.core.model.DefaultPactReader.pactFromJson(PactReader.kt:220)
at au.com.dius.pact.core.model.DefaultPactWriter.writePact(PactWriter.kt:92)
at au.com.dius.pact.core.model.BasePact.write(BasePact.kt:24)
at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.afterAll(PactConsumerTestExt.kt:709)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Again, both classes run individually pass, the first class in the run list passes, even if they're swapped, and the second one throws this error.
Downgrading to v4.6.4 works for now.
🤖 Great news! We've labeled this issue as smartbear-supported and created a tracking ticket in PactFlow's Jira (PACT-1832). We'll keep work public and post updates here. Meanwhile, feel free to check out our docs. Thanks for your patience!
Java 21, dependency version 4.6.5+
from Slack https://pact-foundation.slack.com/archives/C9UN99H24/p1707392044235519
We found an odd issue with the pact jvm consumer dependency update, from version
4.6.5
and up, specifically with query matchers. One provider we use has queries that have square brackets[]
in them, i.e.principle_identifier[account_id]
etc. When running pact tests to generate a contract, running individual test classes runs fine, but as soon as another test class is added to run together, the second class throws errors, seemingly treating the brackets in the query key as an array:Again, both classes run individually pass, the first class in the run list passes, even if they're swapped, and the second one throws this error. Downgrading to v4.6.4 works for now.