Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query keys with angled brackets treated as arrays #1766

Closed
milda-a opened this issue Feb 9, 2024 · 3 comments
Closed

Query keys with angled brackets treated as arrays #1766

milda-a opened this issue Feb 9, 2024 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear

Comments

@milda-a
Copy link

milda-a commented Feb 9, 2024

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:

[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.

@rholshausen
Copy link
Contributor

Can you provide the tests that cause this?

@rholshausen rholshausen added bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear labels Feb 15, 2024
Copy link

🤖 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!

rholshausen added a commit that referenced this issue Feb 16, 2024
@rholshausen
Copy link
Contributor

4.6.7 released with this fix

rholshausen added a commit that referenced this issue Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior smartbear-supported SmartBear engineering team will support this issue. See https://docs.pact.io/help/smartbear
Projects
None yet
Development

No branches or pull requests

2 participants