pact-foundation / pact_broker

Enables your consumer driven contracts workflow
http://pactflow.io
MIT License
708 stars 174 forks source link

Old pacts get recreated even after deletion #566

Closed jeff-hull-ultimate closed 2 years ago

jeff-hull-ultimate commented 2 years ago

Software versions

Expected behaviour

New pacts are created for a consumer, and old pacts that were deleted (via 'delete integration') don't come back.

Actual behaviour

Sometimes, I need to delete certain messages from a pact. However, as it stands, say I have 10 messages in a pact. If I delete one, I expect to then have 9 messages in the pact. Yet the 10th message remains. I tried to set pactfileWriteMode to overwrite, but due to this issue, I'm not able to use the overwrite option.

I thought if I deleted the pacts manually through the UI and then recreated the pacts, the pacts would then be the new version. But I was surprised to see not only were all old fields present in the pact being updated, previously deleted providers for that consumer were recreated as well. For instance, if I delete all 3 pacts for tch-doc-query, and then recreate just the messages for the tch-doc-cmd, the pacts for tch-doc-cmd2 and tch-storage-worker somehow come back to life.

image

Steps to reproduce

I can provide some code snippets if would be helpful to diagnose. Currently, the code is in a private repository.

Relevant log files

thrown: "Could not find command \"overwrite\".
mefellows commented 2 years ago

The simplest solution is to delete the pact file(s) before running the tests. The issue you mentioned is a local issue, not in the broker. The way the message process works is a bit different to HTTP Pact, so that write mode is not possible.

Are you sure you're not publishing a folder where the old pact files exist? How are you publishing to the broker?

My guess is that there was a folder where you were writing the pact files to and the old pacts are still there, and your publish script is eagerly uploading everything in the folder.

bethesque commented 2 years ago

Yes, we've seen this issue in the past, and it has come around because the workspace was not cleared before running the pact tests.

jeff-hull-ultimate commented 2 years ago

Thanks for the super fast response, not cleaning the workspace was indeed the issue. An internal helper library was storing the files outside of the project folder, so that obscured it. Thanks again!

mefellows commented 2 years ago

No worries!