Hi, my team uses the <pact-ruby-standalone> to run...
# pact-ruby
t
Hi, my team uses the pact-ruby-standalone to run provider verification:
Copy code
pact-provider-verifier
  --consumer-version-selector "{\"mainBranch\":true}"
  --consumer-version-selector "{\"deployedOrReleased\":true}"
  --enable-pending
  ...
We have a consumer for which we have never successfully verified their pact, making the pact we have with them "pending". When we run provider verification, the failures are correctly suppressed because of the
--enable-pending
flag. Today a new version of this consumer's pact was published to their main branch with a new request matcher rule in one of the interactions:
Copy code
"path": {
  "combine": "AND",
  "matchers": [
    {
      "match": "regex",
      "regex": ".*([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}).*"
    }
  ]
}
However, in their request they do not provide a
path
, meaning that the regex will never match. When we next ran provider verification as part of our CI/CD, this exception was thrown by the
pact-provider-verifier
and caused our build to exit and fail:
Copy code
.../pact/lib/vendor/ruby/3.3.0/gems/pact-support-1.20.0/lib/pact/term.rb:32:in `initialize': Value to generate "" does not match regular expression /.*([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2}).*/ (Pact::Error)
from .../pact/lib/vendor/ruby/3.3.0/gems/pact-support-1.20.0/lib/pact/matching_rules/v3/merge.rb:105:in `new'
from .../pact/lib/vendor/ruby/3.3.0/gems/pact-support-1.20.0/lib/pact/matching_rules/v3/merge.rb:105:in `handle_regex'
from .../pact/lib/vendor/ruby/3.3.0/gems/pact-support-1.20.0/lib/pact/matching_rules/v3/merge.rb:91:in `wrap'
...
Is there some reason why this exception was not caught and suppressed? The issue is with the request, which we (as the provider) have no control over. Any advice would be appreciated! 😄
y
They look like v3/v4 matchers which are unsupported by pact-ruby, so the consumers should be generating v2 spec files to be compatible with you, or you can upgrade to the pact verifier written in rust which is available as a CLI https://docs.pact.io/implementation_guides/cli#native-binary-new and supports v3/v4 pacts including those matchers. How come they managed to push the pact straight to master and it wasn’t seen via a PR build? I assume it doesn’t normally break you (due to you having enable-pending setup, but this abnormal exit does. This means consumer is blocked from moving forward on main branch as they have no verification, and your provider build is failing because its erroring out?
ps. this sucks! It’s one of the issues with pact spec compat and the older ruby core, and new rust core. users utilising the rust core or pact-jvm can downgrade their pact spec versions and republish, which will give you the correct matchers pact-ruby expect’s
However, in their request they do not provide a
path
, meaning that the regex will never match.
Mmm, that may be a bug in the generating library!
do you have the pact file? does it have some metadata in it to say which lib created it
t
Thanks Yousaf, looks like you're right - using pact-js seems to work fine. How they managed to push the pact straight to master we're not sure... the consumer is only just getting set up with contract testing so I imagine they're pushing to main without using can-i-deploy