Hi folks, I'm using pact-jvm to generate the json ...
# pact-jvm
j
Hi folks, I'm using pact-jvm to generate the json contract as the consumer and using pact-go on the provider side to verify it. However, the verification is failing because the json contract generated by pact-jvm includes an auto-generated interaction key which isn't expected nor desired. It looks like pact-ffi removed key generation in 0.4.5. What is the recommendation here? Example:
Copy code
"interactions": [
    {
      "description": "List bundles request",
      "interactionMarkup": {
        "markup": [...]
      },
      "key": "5050049c",
      "pending": false,
      [...]
      "metadata": {
        "pact-jvm": {
        "version": "4.6.14"
      },
      "pactSpecification": {
        "version": "4.0"
      },
    }
m
When you say it’s failing, can you please share the error?
r
That attribute should make no difference to the verification
j
This is the error I get. Manually removing the interaction key from the json lets the test pass but I'd like to find a better fix.
Copy code
Failed to prepare interaction for verification - Failed to prepare the request: Did not find an interaction that matches the given key '33e79889'
For more context, we are testing a grpc interaction.
r
What version of Pact-Go are you using?
Also, what version of the Protobuf plugin?
j
pact-go is 2.0.8 and go is using protobuf v1.34.2 while the protobuf plugin pact-jvm is using is 0.5.4
Any suggestions here?
r
You will need to look at any debug logs, both from the pact-go run and from the protobuf plugin.
j
Is the expectation that pact-go shouldn't fail due to the interaction key being present? Is this interaction key something that we have to manually verify?
r
No, it's part of the interface to the Protobuf plugin, but there must be a mismatch between the plugin and how Pact-Go is using the underlying FFI functions.
j
I've enabled debug logging and this is what I see
Copy code
2025-02-21T17:37:27.167740Z DEBUG tokio-runtime-worker Connection{peer=Server}: h2::codec::framed_write: send frame=WindowUpdate { stream_id: StreamId(0), size_increment: 983041 }
2025-02-21T17:37:27.167782Z DEBUG tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: tower_http::trace::on_request: started processing request
2025-02-21T17:37:27.167862Z DEBUG tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: pact_protobuf_plugin::server: Received prepare interaction for verification request
2025-02-21T17:37:27.168087Z DEBUG tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: pact_models::v4::http_parts: Body has no content type set, will default to any headers or metadata
2025-02-21T17:37:27.168218Z ERROR tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: pact_protobuf_plugin::server: Did not find an interaction that matches the given key key="919fjalkv0aq9ra0f"
2025-02-21T17:37:27.168242Z DEBUG tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: tower_http::trace::on_response: finished processing request latency=0 ms
2025-02-21T17:37:27.168265Z DEBUG tokio-runtime-worker request{method=POST uri=<http://127.0.0.1:57695/io.pact.plugin.PactPlugin/PrepareInteractionForVerification> version=HTTP/2.0 headers={"te": "trailers", "content-type": "application/grpc", "authorization": Sensitive, "user-agent": "tonic/0.12.2"}}: tower_http::trace::on_eos: end of stream stream_duration=0 ms status=0
2025-02-21T17:37:27.168285Z DEBUG tokio-runtime-worker Connection{peer=Server}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x4: END_HEADERS) }
2025-02-21T17:37:27.168309Z DEBUG tokio-runtime-worker Connection{peer=Server}: h2::codec::framed_write: send frame=Data { stream_id: StreamId(1) }
2025-02-21T17:37:27.168316Z DEBUG tokio-runtime-worker Connection{peer=Server}: h2::codec::framed_write: send frame=Headers { stream_id: StreamId(1), flags: (0x5: END_HEADERS | END_STREAM) }
2025-02-21T17:37:27.177418Z DEBUG tokio-runtime-worker Connection{peer=Server}: h2::codec::framed_read: received frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
m
Any chance you could please try out the latest Pact Go version to rule out any issues there? It’s possibly there is a compatibility issue in the underlying FFI library we use It looks to be fixed in https://github.com/pactflow/pact-protobuf-plugin/commit/4b2c8397394173663a1d68e92dee99b4215df9ae which is included in 0.5.4 (it was released in https://github.com/pactflow/pact-protobuf-plugin/releases/tag/v-0.3.1)
j
tried again after updating to pact-go v2.2.0 and see the same error. Didn't see any logs that print the pact-go version though (wanted them as a sanity check).
r
Can you con firm the version of the pact_ffi shared library that Pact-Go is using? It should log out the version on startup.
j
Sorry to bump this again, is there anything I can do to help debug this further? Our team is planning on making contract tests required for all our features and this has been a pain point as we cannot automate contract generation since we have to manually remove the key in the interaction.
r
I need to replicate it, which take a fair amount of time (it needs a project setup with multiple languages that replicates your setup).
But I think I have an idea where the problem is, just need to verify it.
I have released 0.4.27 of pact_ffi shared library, which hopefully will fix your issue. Not sure what the Pact-Go way of updating that is, but you should just be able to replace the shared library.
m
I’ll push out a minor change today, then you can just re-install the FFI
r
@Matt (pactflow.io / pact-js / pact-go) - No rush at all but did you happen to push out the minor change?
Good news though - I was able to repro @Juan Park’s issue above in the prior Pact FFI version, and after manually bumping the version of Pact FFI (by replacing the dylib on my mac), it does indeed fix the issue. Looking forward to the pact-go version bump thankyou
m
Sorry, this dropped down the list - it’s going out now!
r
No stress, appreciate it!
I think this commit to bump the installer's pact_ffi version didn't make it in the v2.4.0 release. Would you be able to cut another one to include that?
m
Ah, sorry about that - that’s what you get for rushing before a meeting!
Retrying now…