Another broker question - I successfully published...
# pactflow
j
Another broker question - I successfully published my first pact, but I found a mistake. I've since fixed the test, and it is correctly making the new contract, but when I go to publish, the older version is overwriting the new version. I've updated the consumer app version and the tag, and am getting this message:
Copy code
Pact successfully published for flow-controller version v7 and provider normalizer.
  View the published pact at <https://my-company.pactflow.io/pacts/provider/normalizer/consumer/flow-controller/version/v7>
  Events detected: contract_published, contract_content_changed (first time any pact published for this consumer with consumer version tagged v7)
y
it is correctly making the new contract, but when I go to publish, the older version is overwriting the new version
the Pact Broker doesn’t allow you to overwrite published contract contents, which is why you need to publish against a new version. It isn’t overwriting anything
I’ve updated the consumer app version and the tag, and am getting this message:
The recommendation is to publish with
branch
not
tag
. or if you wish to use tags, use
branch
as well (so the Pact Broker knows if your pacts relate to the configured
main
branch) The message is expected, what are you expecting? The Pact Nirvana setup, would now have a webhook setup which would be triggered by the contract being published, this would trigger a provider verification task, where it would be provided the url of the contract to verify. If you haven’t done the ci/cd workshop, it would be highly recommended as it teaches you these concepts 👍
j
I've not only done the ci/cd workshop, but I've actually successfully implemented the full webhook verification flow across multiple contracts at a previous company. Right now I'm starting on a new project.
publish against a new version
I thought I was doing this by updating the
--consumer-app-version
tag. So you're saying I need to update the
--branch
version to get the new pact published?
y
awesome! the message you’ve posted shows the pact has successfully been published, so I’m not sure what the issue is elmo shrug
ie 1. you published first on one tag, updated contract and tried to publish with same version = not vegan 2. you updated tag and tried to publish = ✅
j
on step 2, the older pact is overwriting the new pact
like it's missing a new field and the matchers that I added
1. run consumer tests, which writes a new pact file with the correct fields 2. run publish command with updated version tag 3. that same pact file is now missing those fields
y
> 1. that same pact file is now missing those fields same pact by version or tag? is this when viewing in the pact broker? It would be useful if you can create a simple repro steps by providing the commands you are using to publish, that way we can replicate it and see if we get the same behaviour
I’m going to test out this scenario now and see what happens 👍
1. Create new Pact 2. Publish pact
pact-broker publish pact.json --consumer-app-version 1 --tag 1
3. Update contract with a new field
foo
4. Publish pact again
pact-broker publish pact.json --consumer-app-version 1 --tag 1
a. This published fine, overwriting the contents, and warning about content versioning.
j
is this when viewing in the pact broker?
This is when viewing the pact json file in my editor locally
same pact by version or tag?
By branch name. I've updated both the tag and the version. This is my publish command (running in docker compose)
Copy code
pact-broker publish pacts --consumer-app-version=v7 --branch=my-branch-name --tag=v7 --verbose
Running in the
pactfoundation/pact-cli:latest
container
y
are you deleting old pacts between the test runs?
j
I mean it's overwriting the existing file because it has the same name
y
and the matchers and updated content is in that pact file?
j
yes
then I run that publish command, and the file reverts back to its old state
even when updating the
--branch
param to something else, it's still reverting back to the old version
y
So tested against another PactFlow broker, as the test broker is setup for (https://docs.pact.io/pact_broker/configuration/settings#allow_dangerous_contract_modification) which allows me to overwrite Pact’s. I can replicate the message of the contract not allowing modification, so forcing me to publish with a new version. I can see both versions in the pact broker, with the changes pre and post change, against each respective version
You’ll note the urls are different, to denote the different versions.
j
Oh yeah I'm getting the different version URL's and everything, but see how yours actually has "foo":"bar" in one but not the other? Yeah my "foo bar" is missing from both
if it helps, this is in the request not the response if that changes anything
y
most bizarre! could you try using a diff name for consumer/provider to use a new integration to see if its a glitch in the matrix i’ll try a req change 👍
what was the req change? path, param, header? just so I can try and mirror the same
assume state/desc was the same?
j
I'll dm you the exact pact files
thank you 1