Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple integrations with same Consumer and Provider cause to pact file write errors #509

Closed
arnoldsi-payo opened this issue Jul 2, 2024 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer

Comments

@arnoldsi-payo
Copy link

Version information:

  • OS: MacOS ARM
  • PactNet Version: 4.5.0
  • .Net Version: 8.0.0
  • Pact Broker Version (if applicable): pactflow

following conversation here: https://app.slack.com/client/T5F60FXSQ/C5F4KFKR8
There are two sets of integrations (same consumer and same provider:
Consumer -> HTTP Provider (Provider 1)
Consumer -> Messaging Provider (Provider 1)

This is HTTP integration file

var pact = Pact.V3("Cart API", "Products API", pactConfig);
_pactBuilder = pact.WithHttpInteractions();

This is a messaging integration file

var pact = Pact.V3("Cart API", "Products API", pactConfig);
_pactBuilder = pact.WithMessageInteractions();

When I run it, I get the following error.

Test method Cart.API.Tests.ProductsEventsTests.ReceiveSomeProductsEvents threw exception: 
PactNet.Exceptions.PactMessageConsumerVerificationException: The message could not be verified by the consumer handler ---> System.InvalidOperationException: The pact file could not be written
    at PactNet.Drivers.AbstractPactDriver.WritePactFile(String directory)
   at PactNet.ConfiguredMessageVerifier.Verify[T](Action`1 handler)
--- End of inner exception stack trace ---
    at PactNet.ConfiguredMessageVerifier.Verify[T](Action`1 handler)
   at Cart.API.Tests.ProductsEventsTests.ReceiveSomeProductsEvents() in /Users/arnoldsi/Desktop/dev/Pact-Demo/poc-pactflow-consumer-1/Cart.API.Tests/ProductsEventsTests.cs:line 39.
@arnoldsi-payo arnoldsi-payo added bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer labels Jul 2, 2024
@mefellows
Copy link
Member

As discussed on slack, this is because you're generating a V3 spec pact file which doesn't support serialising mixed interaction types.

The new beta version of Pact .NET will support this as it can generate V4 pacts

@arnoldsi-payo
Copy link
Author

@mefellows, are there any updates on when the stable version will be released? It's very problematic to integration beta versions in our Enterprise

@YOU54F
Copy link
Member

YOU54F commented Jul 2, 2024

we need people to use the library and provide feedback.

the beta status shouldn't be an issue and isn't our concern as maintainers, that you are unable to run betas in enterprise.

the best solution for you with v3 capabilities is to name your message provider differently than your http provider as has always been the guidance for v3 pacts

@YOU54F
Copy link
Member

YOU54F commented Jul 2, 2024

path to release is here as set out the this repos maintainer

https://github.com/pact-foundation/pact-net/milestone/5

@arnoldsi-payo
Copy link
Author

we need people to use the library and provide feedback.

the beta status shouldn't be an issue and isn't our concern as maintainers, that you are unable to run betas in enterprise.

the best solution for you with v3 capabilities is to name your message provider differently than your http provider as has always been the guidance for v3 pacts

In this case, I must manage the connection between consumers and providers in some DB, in order to "group" different integrations of the same consumer-provider

@adamrodger
Copy link
Contributor

The roadmap for v5 is close now, with some final issues to fix and testing to perform.

I've been using the beta for a few months now in production and not had any issues, so I'd encourage you to give it a try in the meantime if the alternatives suggested above don't work for you 👍

@adamrodger adamrodger closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
@adamrodger
Copy link
Contributor

Closed just because there's no planned change here. The "fix" for this use case is in v5 and pact specification v4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior triage This issue is yet to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants