Skip to content

Conversation

@YOU54F
Copy link
Member

@YOU54F YOU54F commented Dec 15, 2025

There was an overlap when introducing #728

which resulted in

/pacts/provider/{provider}/consumer/{consumer}/branch/{branch}/latest returning pact-versions, not the expected latest pact content, for a named branch of an application pair.

I have appended new routes with /versions to match existing pact_publications resource.

It does not append /versions to pact_publications_for_branch route, as this is also used for deleting Pact versions for branch (such supporting deleting pacts by branch was introduced in the UI).

There was an overlap when introducing #728

which returns pact versions, not pact publications.

This may have introduced some confusion in #858 with new HAL relations

appended new routes with /versions to match existing pact_publications resource
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_main_branch"}
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name, "latest"], Api::Resources::PactVersionsForBranch, {resource_name: "latest_pact_publications_for_branch"}
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", :branch_name], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_branch"}
add ["pacts", "provider", :provider_name, "consumer", :consumer_name, "branch", "versions"], Api::Resources::PactVersionsForBranch, {resource_name: "pact_publications_for_main_branch"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this endpoint never be accessible, because the trailing versions static path item might match the dynamic :branch_name path parameter on line 36?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good catch, added some tests in to cover this, and the initial bug of overwriting the original endpoint which returned pact content

query = self
query
branch_versions_join = {
Sequel[:branch_versions][:version_id] => Sequel[:pact_publications][:consumer_version_id],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In adding tests, I noted that I negated to add in logic to scope this to main branches 😅 added now 👍🏾


it "returns the latest pact for the branch" do
expect(json_response_body[:_links][:self][:href]).to end_with("2")
expect(json_response_body[:interactions].length).to eq(1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will catch the original bug, by ensuring we get pact content returned from this endpoint

@YOU54F YOU54F requested review from Saup21 and mefellows January 2, 2026 15:47
@YOU54F
Copy link
Member Author

YOU54F commented Jan 2, 2026

Would appreciate a re-review, have added tests to cover the newly added endpoints which exposed a discrepancy with one of the logic flows which is mopped up now.

danke danke

@YOU54F YOU54F merged commit 45a8147 into master Jan 6, 2026
21 checks passed
@YOU54F YOU54F deleted the fix/restore/latest_pact_for_branch_endpoint branch January 6, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants