Hi, I also put this in pact-jvm channel but I'm un...
# pactflow
r
Hi, I also put this in pact-jvm channel but I'm unsure if that's correct or if this would be the right channel ... we are trying to get Pact JVM's matchQuery() to work with PactFlow's Hosted Stubs. Because matching rules are a requirement for us, we are using Pact v2 contracts. In our efforts to try and get dynamic query parameters working, we are facing the below error:
Copy code
Error from Pactflow stub: Pact::Error - Value to generate \"[\"string\"]\" does not match regular expression /[A-Za-z0-9]{1,}/
For reference, we have tried both of the two ways (one including a custom example, and the other not):
Copy code
// Example not included (Pactflow generates randomly)
pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}");
// Example included
pactDslRequestWithPath = pactDslRequestWithPath.matchQuery(parameter.getName(), "[A-Za-z0-9]{1,}", "string");
Here is the relevant part of the contract that was generated:
Copy code
"request": {
   "method": "GET",
   "path": "<path>",
   "query": "response_type=string&client_id=string&redirect_uri=string&state=string&scope=string",
   "matchingRules": {
      <path>,
      "$.query.response_type": {
         "match": "regex",
         "regex": "[A-Za-z0-9]{1,}"
      },
      "$.query.client_id": {
         "match": "regex",
         "regex": "[A-Za-z0-9]{1,}"
      },
      ...
}
We were facing similar issues with machPath() when we were not including the example, but including the custom example worked in that case. Has anyone got this feature working with v2 contracts? Am I missing something?