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

Message pact is being compared without matchers #1509

Open
sanderdeneve-tomtom opened this issue Feb 2, 2022 · 2 comments
Open

Message pact is being compared without matchers #1509

sanderdeneve-tomtom opened this issue Feb 2, 2022 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@sanderdeneve-tomtom
Copy link

sanderdeneve-tomtom commented Feb 2, 2022

In one project, I'm using MessagePactBuilder from dependency au.com.dius.pact:consumer:4.3.4 to build a spec:

{
"consumer": {
"name": "My Consumer"
},
"interactions": [
{
...
"contents": {
"content": {
"after": 1,
"before": 1,
"userId": 1
},
"contentType": "application/json",
"encoded": false
},
"description": "some description",
"key": "c6dda921",
"matchingRules": {
"content": {
"$.after": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
},
"$.before": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
},
"$.userId": {
"combine": "AND",
"matchers": [
{
"match": "number"
}
]
}
}
},
"metadata": {
"LogicalResourceId": "foo",
"contentType": "application/json"
},
"pending": false,
"type": "Asynchronous/Messages"
}
],
"metadata": {
"pact-jvm": {
"version": "4.3.4"
},
"pactSpecification": {
"version": "4.0"
}
},
"provider": {
"name": "My Provider"
}
}

Make note of the matchingRules with key content.

Now when I run the pact on the provider side, it fails with this error message:

  1. some description: generates a message which has a matching body
    1.1) body: $.after Expected 1 (Integer) but received 4 (Integer)
    1.2) body: $.before Expected 1 (Integer) but received 3 (Integer)
    1.3) body: $.userId Expected 1 (Integer) but received 2 (Integer)

After some debugging, it looks like the following line is always taking body as a category:

val bodyContext = MatchingContext(message.contents.matchingRules.rulesForCategory("body"),

This feels like a bug, wdyt?

EDIT: this seems to be linked solely to V4, as V3 sets the matchingRules with key content

@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Feb 2, 2022
@uglyog
Copy link
Member

uglyog commented Feb 2, 2022

Yes, this does look like a bug

@achawla-Branch
Copy link

achawla-Branch commented May 27, 2022

I stumbled on same issue. @uglyog do you have any plan to fix this in the near term? Thanks

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
Projects
None yet
Development

No branches or pull requests

3 participants