I am running into an API issue with the pactflow A...
# pactflow
r
I am running into an API issue with the pactflow API. I have been using the following API call:
Copy code
curl -H "Accept: application/hal+json" -H "Authorization: Bearer $PACT_BROKER_TOKEN" https://${my_pact_org}.<http://pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/main/latest|pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/main/latest>"
To retrieve the latest version of a contract between two applications on the main branch. This used to work fine for a long time, but since yesterday the response I get no longer contacts the pact
interactions
also the
consumer
and
provider
objects are missing in the json reponse. Did this API change? Is there any other way to retrieve the latest pact (on main) for a pair of applications?
m
I’d be very surprised if it changed - what API response do you get instead?
r
I get the following response: (org and consumer/provider names are redacted)
Copy code
{
  "_embedded": {
    "pacts": [
      {
        "createdAt": "2025-12-08T08:24:04+00:00",
        "_embedded": {
          "consumerVersion": {
            "number": "34c0d03d099b60bb0cef8e45353496804ab34b33",
            "_links": {
              "self": {
                "title": "Version",
                "name": "34c0d03d099b60bb0cef8e45353496804ab34b33",
                "href": "<https://myorg.pactflow.io/pacticipants/MyConsumer/versions/34c0d03d099b60bb0cef8e45353496804ab34b33>"
              }
            }
          }
        },
        "_links": {
          "self": {
            "href": "<https://myorg.pactflow.io/pacts/provider/MyProvider/consumer/MyConsumer/version/34c0d03d099b60bb0cef8e45353496804ab34b33>",
            "title": "Pact between MyConsumer (34c0d03d099b60bb0cef8e45353496804ab34b33) and MyProvider"
          }
        }
      }
    ]
  },
  "_links": {
    "self": {
      "href": "<https://myorg.pactflow.io/pacts/provider/MyProvider/consumer/MyConsumer/branch/main/latest>",
      "title": "All versions of the pact between MyConsumer and MyProvider"
    },
    "consumer": {
      "href": "<https://myorg.pactflow.io/pacticipants/MyConsumer>",
      "title": "Consumer",
      "name": "MyConsumer"
    },
    "provider": {
      "href": "<https://myorg.pactflow.io/pacticipants/MyProvider>",
      "title": "Provider",
      "name": "MyProvider"
    },
    "pact-versions": [
      {
        "href": "<https://myorg.pactflow.io/pacts/provider/MyProvider/consumer/MyConsumer/version/34c0d03d099b60bb0cef8e45353496804ab34b33>",
        "title": "Pact",
        "name": "Version 34c0d03d099b60bb0cef8e45353496804ab34b33 - 08/12/2025"
      }
    ]
  }
}
👍 1
If I explicitly retrieve the url specified at the end (in
pact-versions
) then I do retrieve the full pact contract
m
hmm is it possible you have created a version but not published a pact for that version?
I’m wondering if it’s supposed to return the pact, or provide links to them. e.g.
<https://myorg.pactflow.io/pacts/provider/MyProvider/consumer/MyConsumer/version/34c0d03d099b60bb0cef8e45353496804ab34b33>
is definitely a pact URL
This is the only feature spec relating to it - doesn’t quite clarify the behaviour, hard to tell if it’s changed: https://github.com/pact-foundation/pact_broker/blob/b6aa90f1da1047b7ab50b3d63680f95209649cc3/spec/features/get_latest_pact_for_branch.rb#L4
r
According to https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/api.rb#L81 it returns latest pacts. The endpoint is not really well-documented though. I have previous responses of the API stored. so I am sure I received the actual pacts before. > hmm is it possible you have created a version but not published a pact for that version? No, because I have this issue for all integrations (pairs of consumer/provider) that we have in our landscape
m
I have previous responses of the API stored. so I am sure I received the actual pacts before.
🤔
No, because I have this issue for all integrations (pairs of consumer/provider) that we have in our landscape (edited)
yep sorry, was just a suggestion before I looked into the API itself.
Do you know when that started? Or the last time it definitely worked?
r
It last worked on Dec 3 2025 at 10:19 CET. We have a weekly job (sometimes triggered manually) that runs some analysis on the pact contracts The first failure of the job was on December 8, 2025 at 7:09 CET
thankyou 1
m
@phanindra srungavarapu @Steven Holloway @Yousaf Nabi (pactflow.io) any ideas off the top of your head?
👀 1
y
hmm away from laptop as traveling but will take a look for you tomorrow @Ruud Welling when back in the office. thanks for raising
can you confirm the previous response you have stored?
r
Copy code
{
  "consumer": {
    "name": "MyConsumer"
  },
  "interactions": [
    {
      "_comment": "omitted"
    }
  ],
  "metadata": {
    "pact-jvm": {
      "version": "4.6.17"
    },
    "pactSpecification": {
      "version": "4.0"
    }
  },
  "provider": {
    "name": "MyProvider"
  }
}
Note: The actual content of the interactions has been removed to keep this short. Also my jq script removes the
createdAt
and
_links
keys so my script can easily check if there were changes (have not stored these values)
y
no problem bud, thanks for the additional context. I think this is probably related to changes i did recently in the pact broker, will check when the change was pulled into pactflow, and confirm if there is a regression https://github.com/pact-foundation/pact_broker/pull/728 https://github.com/pact-foundation/pact_broker/pull/858
👀 1
m
Thanks Yousaf. I reckon they were released in that timeframe. Do we know what’s required to fix? I did notice those feature specs didn’t check much aside from links
y
my hunch is there is an overlap in routes, and we are accidentally routing to the wrong controller here. My train of thought is 1. Check when above PR changes made pulled into PactFlow 2. Check release date of above changes. 3. Check route in pact_broker pre and post change (which I assume which show the changed response, for the existing endpoint)
Do we know what’s required to fix?
Not yet without a root cause, could be a route clobber, and the routes need to be better defined, or smth else. Will have a goosey gander
r
Not a ruby expert, but the new resource seems to route to
Api::Resources::PactVersionsForBranch
and the preexisting one routed to
Api::Resources::LatestPact
y
Good spot, yep I inadvertently overlapped an existing route.
Api::Resources::LatestPact
will return the full pact content, and
Api::Resources::PactVersionsForBranch
is designed to return an array of
pacts
of which
latest
returns only the latest, but not the full pact content (has a href, so the consumer can visit it) and reduces the payload when requesting all pact versions from a branch, rather than returning every pacts full content. A workaround for the moment would be to fetch the latest pact url, and visit it in a two step process
Copy code
LATEST_PACT_URL=$(curl -H "Accept: application/hal+json" -H "Authorization: Bearer $PACT_BROKER_TOKEN" https://${my_pact_org}.<http://pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/main/latest|pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/main/latest>" | jq '._links.pacts.[0].href' -r)

curl -H "Accept: application/hal+json" -H "Authorization: Bearer $PACT_BROKER_TOKEN" $LATEST_PACT_URL
you could also omit
main
Copy code
https://${my_pact_org}.<http://pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/latest|pactflow.io/pacts/provider/${provider}/consumer/${consumer}/branch/latest>
which will use the broker recorded property of your main branch, and not the named branch
main
if you do that, the script will still work, when we remove the newly introduced overlapping route
and you also get the benefit of not needing to specify a named branch, and used the recorded applications
mainBranch
property
apologies for the inconvenience!
i think removing that dupe route in pf is a quick way to sort in production, but will also apply in the pact_broker. i wonder as the new routes return pact versions and not pact content are they better prefixed as
/pact-versions
r
Thanks Yousaf. I will have a look and implement this workaround until there is a way again to request the latest pact with just 1 API call
y
PR raised for review https://github.com/pact-foundation/pact_broker/pull/887 renames the conflicting route, and aligns with other routes which return pact-versions
👀 1
thankyou 1