https://pact.io logo
Join Slack
Powered by
# pact-net
  • d

    Dominik Krichbaum

    02/26/2025, 2:22 PM
    @Dominik Krichbaum has left the channel
  • b

    boden winkel

    03/06/2025, 3:10 PM
    Good Morning/Evening all 🙂 We using Bi-Directional approach with testing .net api. One of our .net API serves as a provider, the provider contract itself is a OpenAPI file produced on each build, however... The problem which im struggling now is that our Api is in version V1 and in V2. So do OpenAPI file producing two files one with V1 endpoints spec and second with V2 spec. How to tackle now consumer tests and how to upload actually both files to Pactflow broker ? OR maybe we should use different approach to that.
  • m

    Matt (pactflow.io / pact-js / pact-go)

    03/07/2025, 2:56 AM
    You have two options 1. Join the V1 and V2 versions of the OAS together a. This only works if they are versioned in a way that means they don’t collide. e.g. all urls have base paths like
    /v1/
    or
    /v2
    or you use content negotiation or something 2. Release the new provider under a new name a. e.g.
    provider-v1
    and
    provider-v2
    b
    • 2
    • 1
  • d

    Daniele Del Piano

    03/14/2025, 4:47 PM
    Is there an example to use the provider Middleware with test containers?
  • m

    Matt (pactflow.io / pact-js / pact-go)

    03/14/2025, 9:33 PM
    I'm not aware of any official examples with that combo. What does the introduction of test containers change?
  • d

    Daniele Del Piano

    03/15/2025, 7:34 AM
    Automation and an isolated testing environment
  • m

    Matt (pactflow.io / pact-js / pact-go)

    03/15/2025, 7:56 AM
    I understand what they are, sorry, but I'm wondering what additional information you'd need in our examples to make it work that you couldn't extrapolate on your own? Or put another way, we can't create examples with all combinations of frameworks and tools so we try and highlight the relevant points for users to integrate as needed into their tools. If we could improve that of course we would like to help
  • d

    Daniele Del Piano

    03/15/2025, 9:04 AM
    Well, I've not pretended any of the above. I just simply asked if there is an example? There is not.... That's it. Obviously the question was not restricted to pact Devs but also to everyone that works with it and may have implemented it in this way. I feel like every time I ask about pact features there is a kind of self defense answer.
    m
    y
    • 3
    • 5
  • g

    GitHub

    03/22/2025, 3:25 PM
    1 new commit pushed to
    <https://github.com/pact-foundation/pact-net/tree/master|master>
    by adamrodger
    <https://github.com/pact-foundation/pact-net/commit/c72173242045c5d9d4459d10a2831256c0529164|c7217324>
    - chore(ffi): Upgrade to FFI 0.4.27 pact-foundation/pact-net
  • g

    GitHub

    03/22/2025, 3:29 PM
    1 new commit pushed to
    <https://github.com/pact-foundation/pact-net/tree/master|master>
    by adamrodger
    <https://github.com/pact-foundation/pact-net/commit/8661b21112b6b9e56ba31315d027b5b69602b08c|8661b211>
    - chore(deps): Upgrade to System.Text.Json 8.0.5 pact-foundation/pact-net
  • g

    GitHub

    03/22/2025, 4:00 PM
    1 new commit pushed to
    <https://github.com/pact-foundation/pact-net/tree/master|master>
    by adamrodger
    <https://github.com/pact-foundation/pact-net/commit/171c82c2da0f000d424fd94a1ccd4fe910955d0e|171c82c2>
    - fix(ci): Reinstate triggering releases on pushed tags pact-foundation/pact-net
  • g

    GitHub

    03/22/2025, 4:04 PM
    Release - 5.0.1 New release published by github-actions[bot] pact-foundation/pact-net
  • g

    GitHub

    03/23/2025, 4:44 PM
    #516 Deadlock issue while running test Issue created by HuiSou Previous issues Have you searched the issue tracker to ensure this hasn't been discussed before? • Yes https://github.com/pact-foundation/pact-net/issues?q=is%3Aissue+hangs https://github.com/pact-foundation/pact-net/issues?q=is%3Aissue+freeze https://github.com/pact-foundation/pact-net/issues?q=is%3Aissue+deadlock Version information: • OS: Ubuntu 22 • PactNet Version: 4.5.0 • .Net Version: 8.0.108 • Pact Broker Version (if applicable): N/A Describe the bug I create a pact builder with multiple interaction and try to invoke the call via WebApplicationFactory in my API integration test, and some of my test run are getting stucked and here's the problem I discovered during --blame [image](https://private-user-images.githubusercontent.com/8407412/363959327-47af8349-c615-4023-aa5e-7a04138c7c38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NDI3NDg1ODksIm5iZiI6MTc0Mjc0ODI4OSwicGF0aCI6Ii84NDA3NDEyLzM2Mzk1OTMyNy00N2FmODM0OS1jNjE1LTQwMjMtYWE1ZS03YTA0MTM4YzdjMzgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDMyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAzMjNUMTY0NDQ5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjBmYzU1OGY4MTQzMzY5NzI4NTFhMTU3MmM0MmYwZDE5NzNlY2NkODNkMGU1MTZjOGQ4NTlmN2M5Yjk3NDhjOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.Vk_nBQm4I3yASHrtPzK9CYHBFA49PfCbEubEvFx2-VE) *notice the duplicate call of PactNet.Interop.NativeInterop.CleanupMockServer(Int32), this might cause pact_ffi mutex lock each other Steps To Reproduce • Create PACT builder with 15 interaction • Create webServer via WebApplicationFactory and change the congfiguration to mockServercontext • run api test to get information until it failed, for instance
    Copy code
    while true; do dotnet test  MyApp.Integrationtest --blame-hang  --blame-hang-timeout 10000 ; sleep 1; done
    • once the test hangs, use dotnet-dump to analyze issue Expected behavior A clear and concise description of what you expected to happen. • test should not hangs Log Output Applicable log output. Please ensure you remove any sensitive information.
    Copy code
    00007F04EACEB710 00007f468de3488d [InlinedCallFrame: 00007f04eaceb710] PactNet.Interop.NativeInterop.CleanupMockServer(Int32)
    00007F04EACEB710 00007f46199bc919 [InlinedCallFrame: 00007f04eaceb710] PactNet.Interop.NativeInterop.CleanupMockServer(Int32)
    00007F04EACEB700 00007F46199BC919 ILStubClass.IL_STUB_PInvoke(Int32)
    00007F04EACEB790 00007F46199BC88A PactNet.Drivers.MockServerDriver.ReleaseUnmanagedResources()
    00007F04EACEB7B0 00007F46199BC848 PactNet.Drivers.MockServerDriver.Dispose()
    00007F04EACEB7D0 00007F4613B9D36C PactNet.PactBuilder+<VerifyAsync>d__9.MoveNext()
    00007F04EACEB7F0 00007F4613B9D2D5 PactNet.PactBuilder+<VerifyAsync>d__9.MoveNext()
    00007F04EACEB850 00007F461997BF01 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[PactNet.PactBuilder+<VerifyAsync>d__9, PactNet]].ExecutionContextCallback(System.Object)
    00007F04EACEB870 00007F4613878091 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
    00007F04EACEB8C0 00007F461997BDB4 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[PactNet.PactBuilder+<VerifyAsync>d__9, PactNet]].MoveNext(System.Threading.Thread)
    00007F04EACEB910 00007F461997BCAA System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[PactNet.PactBuilder+<VerifyAsync>d__9, PactNet]].MoveNext()
    00007F04EACEB930 00007F4613BA9B09 Xunit.Sdk.AsyncTestSyncContext+<>c__DisplayClass7_0.<Post>b__0() [/_/src/xunit.execution/Sdk/AsyncTestSyncContext.cs @ 58]
    00007F04EACEB970 00007F4612014FF3 Xunit.Sdk.XunitWorkerThread+<>c.<QueueUserWorkItem>b__5_0(System.Object) [/_/src/common/XunitWorkerThread.cs @ 37]
    00007F04EACEB9B0 00007F4613878091 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
    00007F04EACEBA00 00007F460E817994 System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
    00007F04EACEBC50 00007f468da26413 [DebuggerU2MCatchHandlerFrame: 00007f04eacebc50]
    Additional context Add any other context about the problem here. pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    03/23/2025, 7:06 PM
    1 new commit pushed to
    <https://github.com/pact-foundation/pact-net/tree/master|master>
    by adamrodger
    <https://github.com/pact-foundation/pact-net/commit/b3c2fe14a513a886dab165721b156526765690fa|b3c2fe14>
    - chore: Delete some old unused tests pact-foundation/pact-net
  • g

    GitHub

    03/27/2025, 1:35 PM
    #534 RFC: Throw explicit timeout errors on verification Issue created by isaac-r ## Issue When running the verifier if the verify method times out there is nothing in the logs to explain the issue is timeout rather than a failing pact verification. ## Solution Add explicit timeout messaging in the
    Execute
    method of
    pact-net\src\PactNet\Verifier\InteropVerifierProvider.cs
    by passing down the
    timeout
    Timespan from
    pact-net\src\PactNet\Verifier\PactVerifierSource.cs
    . Wrapping the result in a try-catch, the explicit timeout exception can be caught and thrown back up. ## Further work I have encountered further issues with no explanations in the errors dure to the limited feedback from the pact-core errors. It would be useful to log config/set up errors with the pact server and return status codes when running the mock server if requests fail or if the application stop unexpectedly. ## Alternatives This could be done in pact-core and updated with additional errors for connection issues to the mock server pact-foundation/pact-net
  • i

    Isaac Richardson

    03/28/2025, 9:41 AM
    Hi, I'm trying to run my app using minimal api in .NET 9 but I'm running into an issue when using a process to run the app. I am following on advice given in this answer: https://stackoverflow.com/a/77231959/18482058 but I am unable to get my application to keep running within the process (see the discussion under the answer)
    i
    • 2
    • 3
  • m

    Mayamiko K

    03/28/2025, 11:24 AM
    Hi all, We’re looking to implement message-based contract tests for Azure Service Bus messages. The consumer expects certain headers to be included with the messages. Is there a way to specify headers when to be included in the pact? I’ve come across the .WithMetadata method, but I’m not sure if that’s the appropriate approach for setting headers. Thanks!
    m
    • 2
    • 1
  • g

    GitHub

    03/28/2025, 11:33 AM
    #535 Test Host Process Crashes After 5.0.1 Upgrade Issue created by adamrodger Version information: • OS: Linux x64 • PactNet Version: 5.0.1 • .Net Version: 9.0 Describe the bug After the upgrade from PactNet 5.0.0 to 5.0.1, I get an error when running provider tests inside a .Net Docker container:
    Copy code
    The active test run was aborted. Reason: Test host process crashed
    
    Test Run Aborted.
           _VSTestConsole:
             MSB4181: The "VSTestTask" task returned false but did not log an error.
         1>Done Building Project "/app/tests/MyProject.Pacts/MyProject.Pacts.csproj" (VSTest target(s)) -- FAILED.
    
    Build FAILED.
        0 Warning(s)
        0 Error(s)
    
    Time Elapsed 00:00:03.52
    Process exited with code 1
    Test ignored: MyProject.ProviderTests.VerifyPacts, ignore reason: Interrupted by build execution timeout
    Consumer tests work absolutely fine, it's only provider tests that crash. Steps To Reproduce Unsure currently - it was working fine before the upgrade Additional context The diff between 5.0.0 and 5.0.1 only really has an FFI upgrade in it, so I'm assuming the issue is there and that it's crashing the provider tests. pact-foundation/pact-net
  • e

    Erich Zimmerman

    04/01/2025, 9:35 PM
    @Erich Zimmerman has left the channel
  • j

    Jordi March

    04/09/2025, 12:52 PM
    Hi! We are working on the implementation of PACT in some API projects. We have the following case: One of the endpoints returns an array, and the problem we encountered during provider validation was that the order defined in the contract was different from the one returned by the API. For now, we have resolved it by sorting the array in the contract to match what the provider returns. However, our question is if there is any other way to do this and what best practices we can apply in this case. Thanks!
    i
    • 2
    • 4
  • g

    GitHub

    04/22/2025, 1:46 PM
    #538 Messaging pacts - guidelines to provide real message to verifier Issue created by scrocquesel-ml150 I'm working on implementing the messaging verifier. In my case, the provider sends messages to an Azure Service Bus in response to certain interactions. I want to verify that these messages conform to the consumer pact. Looking at the examples, it seems that messages are manually constructed in the tests. #459 call them canned message. IMHO, this introduces a risk of divergence between the actual messages sent by the application and the ones defined in the test. What I’ve done instead is configure the provider to send messages to a Service Bus Testcontainer during integration tests. A MessageProcessor dequeues the messages and transforms them into Pact scenarios. Once all integration tests have passed, I use the collected scenarios with the message pact verifier. What do you think of this approach? pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    04/24/2025, 7:28 AM
    #539 Request/Response and messaging in same service; how do we filter? Issue created by robbiewareham I am using PactNet 5.0.1 and I have a service that provides the following: • POST request is made to my service which results in a message being written to a 3rd party queue. I now have two pact files hosted in PactBroker; one generated by the consumer of the POST endpoint, the other generated by the process that reads the messages from the queue. I've implemented the verification by having 2 classes, each with one Xunit test. One class uses
    MessagingProvider
    and is configured to download from a pact broker:
    Copy code
    using var verifier = new PactVerifier(config);
       
     verifier.MessagingProvider("personal-details-api", CreateJsonSettings())
             .WithProviderMessages(scenarios =>
             {
                 scenarios.Add("An event is created", _event);
             })
             .WithPactBrokerSource(_pactBrokerUri)
             .Verify();
     }
    I was hoping/assuming that this would only download the messaging pact from pact broker but it is also downloading the request/response pact too so fails as it only expects messages. The "provider" name in Pact Broker is the same (which makes sense to me as the provider is the same), but do I have to have unique provider names? pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    05/06/2025, 5:08 PM
    #540 How to authenticate to the Provider target endpoint ? Issue created by rpbs Version information: • PactNet Version: 5.0.1 • .Net Version: 8 Describe the bug Not a bug but I'm not being able to pass Authorization with a Bearer to the header of the Pact Uri Steps To Reproduce I have a pact verifier, I need to be able to authenticate to the Provider Uri.
    httpVerifier.WithHttpEndpoint(providerUri)
    Then I'm calling
    Verify()
    method Log Output I'm getting 401 Could you guys help me to understand what I'm missing ? pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    05/27/2025, 5:21 PM
    #541 feat(verifier): Added support of set_no_pacts_is_error feature Pull request opened by levanoz Added support for the set_no_pacts_is_error feature, implemented similarly to how it's done in pact-js and other Pact libraries. pact-foundation/pact-net
  • d

    Dimitris Dranidis

    06/05/2025, 3:29 PM
    Hi, We have a provider test of an AMQP interaction in Pact. The interaction has a "description" and "providerStates". We added in the test:
    Copy code
    .WithMessages(scenarios =>  {
                        scenarios.Add(
                            "scenario description",
                            builder => SetupDescriptionA(builder));
                    }, _serializerOptions) ...
    and the state handler "prepare data" in the middleware. I would expect the state handler to execute FIRST to prepare the data for the content of the message, and THEN the description handler to execute SECOND so that it uses a messageProducer function to generate the message based on the prepared data, But it is the opposite! This forces us to abandon providerStates and only use descriptions for both setting the environment and producing the message. In case, I misunderstand something please let me know. Thank you in advance!
    m
    • 2
    • 3
  • g

    GitHub

    06/06/2025, 3:36 PM
    #542 Sequence of "description" and "providerStates" in messaging provider verification. Issue created by dranidis Version information: • OS: Arch Linux • PactNet Version: 5.0.1 • .Net Version: 8.0.100 • Pact Broker Version (if applicable): NA Describe the bug Description handler is executed before the state handler. Steps To Reproduce The current behaviour can be reproduced with the code in this repo:
    <https://github.com/dranidis/pact-dotnet-message-provider>
    Expected behavior We have a provider test of an AMQP interaction in Pact. The interaction has a "description" and "providerStates". We added in the test:
    Copy code
    .WithMessages(scenarios =>  {
                        scenarios.Add(
                            "scenario description",
                            builder => SetupDescriptionA(builder));
                    }, _serializerOptions) ...
    and the state handler "prepare data" in the middleware. I would expect the state handler to execute FIRST to prepare the data for the content of the message, and THEN the description handler to execute SECOND so that it uses a messageProducer function to generate the message based on the prepared data, But it is the opposite! This forces us to abandon providerStates and only use descriptions for both setting the environment and producing the message. In case, I misunderstand something please let me know. pact-foundation/pact-net
  • g

    GitHub

    06/13/2025, 5:10 PM
    #543 RFC: Configure a custom port for the mock server Issue created by scrocquesel-ml150 Is your feature request related to a problem? Please describe. I'm running Pact on the host and the client is in a testcontainer. Having a container call the host is a bit difficult and testcontainer has some helpers but it requires to know the server port in advance. Describe the solution you'd like I want to configure the pact listening port in the Options instead of relying on the FindUnusedPort. Breaking Changes No, if the port is not configured, it use the FindUnusedPort. Potential Downsides/Caveats The user is responsible to pass port that is not currently used. Describe alternatives you've considered Start pact first but not very convenient in how the test fixture are writtent Additional context The Js version has such a config https://github.com/pact-foundation/pact-js/blob/8c8348b5188b8819f90b10d26834c222e4e7b744/src/v4/http/types.ts#L34-L37 pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    06/14/2025, 1:33 PM
    #514 Improve target frameworks and their package references: Pull request opened by SymbioticKilla Hi @adamrodger, sorry for PR before creating an issue to discuss. I think it is easier to discuss it within PR, if you are interested in this change. 1.) Add net8.0 as a target framework to support latest LTS version and to use latest compile improvements with less package references 2.) Add conditions for package references => net8.0 doesn't need them 3.) Remove net462 => netstandard2.0 is already a compatibility mode framework to support all .NET versions. There is no need to specify old .NET frameworks. 4.) All projects except nuget projects can reference only net8.0. There is no need for multiple target frameworks pact-foundation/pact-net
    • 1
    • 1
  • g

    GitHub

    06/14/2025, 1:34 PM
    #523 chore(deps): bump System.Text.Json from 8.0.2 to 8.0.5 in /src/PactNet.Abstractions Pull request opened by dependabot[bot] Bumps System.Text.Json from 8.0.2 to 8.0.5. [Dependabot compatibility score](https://camo.githubusercontent.com/83a80808250b8d7de5b1c5c1881019cdb26e6e54015140cf9970290c2096bdff/68747470733a2f2f646570656e6461626f742d6261646765732e6769746875626170702e636f6d2f6261646765732f636f6d7061746962696c6974795f73636f72653f646570656e64656e63792d6e616d653d53797374656d2e546578742e4a736f6e267061636b6167652d6d616e616765723d6e756765742670726576696f75732d76657273696f6e3d382e302e32266e65772d76657273696f6e3d382e302e35) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
    @dependabot rebase
    . --- Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: •
    @dependabot rebase
    will rebase this PR •
    @dependabot recreate
    will recreate this PR, overwriting any edits that have been made to it •
    @dependabot merge
    will merge this PR after your CI passes on it •
    @dependabot squash and merge
    will squash and merge this PR after your CI passes on it •
    @dependabot cancel merge
    will cancel a previously requested merge and block automerging •
    @dependabot reopen
    will reopen this PR if it is closed •
    @dependabot close
    will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually •
    @dependabot show <dependency name> ignore conditions
    will show all of the ignore conditions of the specified dependency •
    @dependabot ignore this major version
    will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) •
    @dependabot ignore this minor version
    will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) •
    @dependabot ignore this dependency
    will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the Security Alerts page. pact-foundation/pact-net
    • 1
    • 1
  • r

    Ryan Child

    06/18/2025, 3:00 PM
    Hey everyone, is there a way to specify the URL to use for pact messages? It seems to grab the base URL from the "WithHttpEndpoint" method and slaps on a port + "/pact-messages". The issue is that the URL we pass in when running this in a pipeline is an APIM URL, so it gets a 404. We need it to use localhost when calling for the pact messages
    m
    • 2
    • 4
1...56789Latest