Ulises Cervino
01/10/2024, 2:19 PMqueryParameterFromProviderState from java-land?Matt (pactflow.io / pact-js / pact-go)
fromProviderState, which can be used where matchers are used, in this case on the query propertyUlises Cervino
01/11/2024, 6:56 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/12/2024, 6:41 AM"query": {
"$.entityVersion[0]": {
"expression": "${v2Version}",
"type": "ProviderState"
}
}Ulises Cervino
01/12/2024, 6:42 AMPOST /path/to/entity?entityVersion=${v2Version} or entityVersion=[${v2Version}]?Ulises Cervino
01/12/2024, 6:43 AMMatt (pactflow.io / pact-js / pact-go)
entityVersion[]= style). I believe it will store the parameters as an array though in the contractMatt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/15/2024, 5:32 AMMatt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/15/2024, 8:10 AM{
"version": [
"741ffe00-8c59-4275-bdd5-385b8249b992"
]
}
and more like
{
"version": "741ffe00-8c59-4275-bdd5-385b8249b992"
}
insteadUlises Cervino
01/15/2024, 8:11 AMparam=value¶m=value… right?Matt (pactflow.io / pact-js / pact-go)
rholshausen
01/16/2024, 3:30 AMMatt (pactflow.io / pact-js / pact-go)
rholshausen
01/16/2024, 4:17 AMMatt (pactflow.io / pact-js / pact-go)
rholshausen
01/16/2024, 5:51 AMrholshausen
01/16/2024, 5:54 AMUlises Cervino
01/16/2024, 7:53 AM.query(&[("foo", "a"), ("foo", "b")]) gives "foo=a&foo=b" ’ seems to imply that
"query": {
"$.entityVersion[0]": {
"expression": "${v2Version}",
"type": "ProviderState"
}
}
should result in requests which end with ?entityVersion=UUID_HERE, or am I misreading?Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
@pact-foundation/pact-core dependencyUlises Cervino
01/17/2024, 6:52 AMMiguel Heitor
01/18/2024, 9:19 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
npm list @pact-foundation/pact-core
in the project that’s not working?Miguel Heitor
01/18/2024, 10:35 AMMiguel Heitor
01/18/2024, 10:44 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 10:45 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 10:46 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
MessageStateHandlersMiguel Heitor
01/18/2024, 10:47 AMMiguel Heitor
01/18/2024, 10:48 AMMiguel Heitor
01/18/2024, 11:15 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 11:25 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 11:26 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 11:27 AMMiguel Heitor
01/18/2024, 11:28 AMquery: {basketVersion: fromProviderState('${basketV2Version}', v2Version)}, inside the provider.withRequestMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 11:36 AM"query": {
"$.basketVersion[0]": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
this part?Matt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 11:42 AMUlises Cervino
01/18/2024, 11:42 AMstate.put("basketV2Version", internalBasketV2.getBasketVersionUUID());Ulises Cervino
01/18/2024, 11:42 AMMatt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/18/2024, 11:59 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/18/2024, 12:02 PM"query": {
"basketVersion": {
"dataType": "STRING",
"expression": "basketVersion",
"type": "ProviderState"
}
}Ulises Cervino
01/18/2024, 12:02 PMMatt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/18/2024, 12:03 PM@PactTestFor(pactMethod = "updateBasketPutAsyncV2", pactVersion = PactSpecVersion.V3)Miguel Heitor
01/18/2024, 12:05 PMconst mockProvider = new PactV3({ so think it should be the same. (btw, im new here, seeing all of this for the first time)Matt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/18/2024, 12:06 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
"query": {
"$.basketVersion[0]": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
It comes via this call in the JS client:
query: {basketVersion: fromProviderState('${basketV2Version}', v2Version)}, inside the provider.withRequest (edited)
On the provider side, when verifying, they use this to inject the parameter:
state.put("basketV2Version", internalBasketV2.getBasketVersionUUID());
However, the value in the contract is still used.
When looking at another test that does work (generated by Java), the generator in the contract looks different:
"query": {
"basketVersion": {
"dataType": "STRING",
"expression": "basketVersion",
"type": "ProviderState"
}
}
It’s curious that both the expression is different (no $ business) and there is also no path to basketVersion in this contract.
Both are version 3 contracts, apparently.rholshausen
01/18/2024, 10:49 PM$.basketVersion[0], that is what the fix I released addressed. I.e., with this expression, the generator won't match the proper query string value, it will try create a query string like ?%24.basketVersion%5B0%5D=VALUE and not ?basketVersion=VALUErholshausen
01/18/2024, 10:50 PM"expression": "basketVersion" and "expression": "${basketVersion}" are equivalentMatt (pactflow.io / pact-js / pact-go)
rholshausen
01/18/2024, 10:53 PM"query": {
"$.basketVersion[0]": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
will do anything. I'm pretty sure the process works by going through the query parameters and looks for a matching query parameterMatt (pactflow.io / pact-js / pact-go)
rholshausen
01/18/2024, 10:53 PM$.basketVersion[0] it will never get appliedMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
pact-core version.
After an npm update @pact-foundation/pact-core in a test project and then creating a version, I get the fixed generator:
"generators": {
"query": {
"basketVersion": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}Matt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/19/2024, 6:10 AMMatt (pactflow.io / pact-js / pact-go)
generators section with the correct one and running the Java test with it. If that passes, we know it’s an issue with the contract serialisationMatt (pactflow.io / pact-js / pact-go)
just to add/confirm: it’s the wrong matcher that’s tripping us up, not the value, etc. because for pact-jvm it all works as expectedyou use the word “matcher” here, and not generator. Just want to make sure we’re on the same page too! I haven’t looked at the matcher for this either, but the generator was definitely wrong. The generator is what’s used during provider verification, where a value is generated dynamically. In this case, the generator gets the dynamic value from
state.put(..) expression.
my understanding is that this expression is having no effect, so the default value in the contract is being used. Is that correct?Matt (pactflow.io / pact-js / pact-go)
"generators": {
"query": {
"$.basketVersion[0]": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
},
"matchingRules": {
"query": {
"$.basketVersion[0]": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
},
but are fixed in the latest:
"generators": {
"query": {
"basketVersion": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
},
"matchingRules": {
"query": {
"basketVersion": {
"combine": "AND",
"matchers": [
{
"match": "type"
}
]
}
}
}Ulises Cervino
01/19/2024, 6:49 AMyou use the word “matcher” here, and not generator. Just want to make sure we’re on the same page too!sorry, still learning the terminology 🙂
Ulises Cervino
01/19/2024, 6:49 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
pact-core) is in the project that would helpUlises Cervino
01/19/2024, 7:01 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/19/2024, 7:58 AM➜ bash git:(antripathi/CT-basketversion2) npm list @pact-foundation/pact-core
nodejs@0.0.1 /Users/mheitor/git_tree/nodejs
├── @pact-foundation/pact-core@14.0.6
└─┬ @pact-foundation/pact@12.1.2
└── @pact-foundation/pact-core@14.0.6 deduped
➜ bash git:(antripathi/CT-basketversion2) npm list @pact-foundation/pact
nodejs@0.0.1 /Users/mheitor/git_tree/nodejs
└── @pact-foundation/pact@12.1.2Miguel Heitor
01/19/2024, 8:09 AMMiguel Heitor
01/19/2024, 8:18 AMMiguel Heitor
01/19/2024, 8:19 AMMiguel Heitor
01/19/2024, 9:42 AMMiguel Heitor
01/19/2024, 9:42 AM"generators": {
"path": {
"expression": "/v2/${basketV2Id}/item/${insuranceItemId}",
"type": "ProviderState"
},
"query": {
"basketVersion": {
"expression": "${basketV2Version}",
"type": "ProviderState"
}
}
},Miguel Heitor
01/19/2024, 9:42 AMMiguel Heitor
01/19/2024, 9:54 AMMatt (pactflow.io / pact-js / pact-go)
Miguel Heitor
01/19/2024, 1:09 PMMiguel Heitor
01/19/2024, 1:10 PMUlises Cervino
01/19/2024, 2:53 PMMiguel Heitor
01/19/2024, 2:55 PMUlises Cervino
01/19/2024, 2:55 PMUlises Cervino
01/19/2024, 2:55 PMMiguel Heitor
01/19/2024, 2:55 PMMiguel Heitor
01/19/2024, 2:56 PMUlises Cervino
01/19/2024, 2:57 PMdataType is missing thinking2Miguel Heitor
01/19/2024, 2:58 PMMatt (pactflow.io / pact-js / pact-go)
Ulises Cervino
01/21/2024, 7:26 PMMatt (pactflow.io / pact-js / pact-go)