Hello, I got a problem with the regex generator an...
# general
t
Hello, I got a problem with the regex generator and the pact cli. I got a field with a string matcher using the regex
.{0,255}
(any character, 0-255 symbols). Pact JVM generates an (in my opinion valid) example value of "\u96A1\uD8A4". Pact JVM and the tested code are absolutely fine with this, but when trying to upload the contract file, the Pact CLI throws the following error.
/usr/lib/ruby/gems/3.3.0/gems/json-2.7.3/lib/json/common.rb222in `parse': incomplete surrogate pair at '\uD8A4", (JSON::ParserError)
I assume the ruby json parser assumes, that the unicode surrogate should be followed by a fitting other surrogate. This is a bug right?
y
Can Pact JVM publish the contract okay? (I believe it uses it’s own http client)
t
You mean using the gradle plugin?
Tried to use the link here: https://docs.pact.io/getting_started/sharing_pacts , Seems like 'Publishing to a pact broker' is not longer an anchor tag.
Okay, this is weird... The gradle plugin reports the broker answering with 400 and
Copy code
{
  "errors": {
    "contracts": [
      "content could not be parsed as application/json (at index 0)"
    ]
  }
}
But when I inspect the file myselft it is absolutely fine.
Okay, it gets weirder. As a workaround I modified the regex to be
[\w ]{0,255}
, now the contract tests fail, because the example value of "6 ]]]" (generated by pact) does not match the specified regex. I think the generator thinks it may repeat the closing square bracket of the character list.
Oh I forgot to send the important part: Yes Pact JVM is able to publish the pact!
@Yousaf Nabi (pactflow.io) is it possible, that the problem isn't in pact ruby, but rather in pact-jvm escaping unicode characters in string? For example, "鶠" is represented as "\u9DA0". Isn't this unnecessary?
Seems like others have had similar problems: https://github.com/pact-foundation/pact-jvm/issues/1536
Commented on the issue (even though it is a bit dated) and am waiting for a response from @uglyog there