From ddac23537fd8d33adffbcb4a47609bf37b4faf75 Mon Sep 17 00:00:00 2001 From: Tobias Fischer Date: Fri, 11 Sep 2026 06:54:18 +1000 Subject: [PATCH] fix: use explicit refs/tags/ in GitHub raw package.xml URLs ros2-gbp release tags look like "release/jazzy/foo_pkg/1.2.3-1" -- the short raw.githubusercontent.com /// form has to guess where a slash-containing ref ends and the path begins. That guess is inconsistently cached across CDN edges: the same URL 404s from some vantage points (including GitHub Actions runners, observed repeatedly and reproducibly on RoboStack/ros-jazzy CI) while resolving fine from others. The explicit refs/tags/ form removes the ambiguity and resolves reliably everywhere. A commit hash (rev) is already unambiguous and is left as-is. Co-Authored-By: Claude Sonnet 5 --- vinca/distro.py | 18 ++++++++-- vinca/test_github_raw_url.py | 59 +++++++++++++++++++++++++++++++++ vinca/test_snapshot_metadata.py | 6 ++-- 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 vinca/test_github_raw_url.py diff --git a/vinca/distro.py b/vinca/distro.py index c56010a..1b23bb0 100644 --- a/vinca/distro.py +++ b/vinca/distro.py @@ -543,12 +543,26 @@ def _construct_raw_url_github(self, pkg_info): # Extract owner/repo owner_repo = raw_url_base.split("github.com/")[-1] # Use rev if available, otherwise fallback to tag - ref = pkg_info.get("rev") or pkg_info.get("tag") + rev = pkg_info.get("rev") + tag = pkg_info.get("tag") xml_name = pkg_info.get("package_xml_name", "package.xml") additional_folder = pkg_info.get("additional_folder", "") if additional_folder != "": additional_folder = additional_folder + "/" - raw_url = f"https://raw.githubusercontent.com/{owner_repo}/{ref}/{additional_folder}{xml_name}" + if rev: + # A commit hash is unambiguous as-is. + ref_path = rev + else: + # ros2-gbp release tags look like "release/jazzy/foo_pkg/1.2.3-1" -- + # raw.githubusercontent.com's short /// form + # has to guess where a slash-containing ref ends and the path + # begins, and that guess is inconsistently cached across CDN edges: + # the same URL can 404 from some vantage points (including GitHub + # Actions runners) while resolving fine from others. The explicit + # refs/tags/ form removes the ambiguity and resolves + # reliably everywhere. + ref_path = f"refs/tags/{tag}" + raw_url = f"https://raw.githubusercontent.com/{owner_repo}/{ref_path}/{additional_folder}{xml_name}" return raw_url # format (checked against GitLab 19.x): https://gitlab.com//-/raw// diff --git a/vinca/test_github_raw_url.py b/vinca/test_github_raw_url.py new file mode 100644 index 0000000..b4474aa --- /dev/null +++ b/vinca/test_github_raw_url.py @@ -0,0 +1,59 @@ +from typing import Any + +from vinca.distro import Distro + + +def _distro() -> Any: + return Distro.__new__(Distro) + + +def test_tag_ref_uses_explicit_refs_tags_prefix(): + # ros2-gbp release tags look like "release/jazzy/foo_pkg/1.2.3-1" -- the + # short /// raw.githubusercontent.com form has to + # guess where a slash-containing ref ends and the path begins, and that + # guess is inconsistently cached across CDN edges (the same URL 404s from + # some vantage points, including GitHub Actions runners, while resolving + # fine from others). The explicit refs/tags/ form is unambiguous. + pkg_info = { + "url": "https://github.com/ros2-gbp/ros2_control-release.git", + "tag": "release/jazzy/controller_interface/4.47.0-1", + } + + url = _distro()._construct_raw_url_github(pkg_info) + + assert url == ( + "https://raw.githubusercontent.com/ros2-gbp/ros2_control-release/" + "refs/tags/release/jazzy/controller_interface/4.47.0-1/package.xml" + ) + + +def test_rev_ref_is_used_as_is(): + # A commit hash is already unambiguous -- it must not get the refs/tags/ + # prefix, since it isn't a tag name. + pkg_info = { + "url": "https://github.com/ros2-gbp/ros2_control-release.git", + "rev": "abc123def456", + } + + url = _distro()._construct_raw_url_github(pkg_info) + + assert url == ( + "https://raw.githubusercontent.com/ros2-gbp/ros2_control-release/" + "abc123def456/package.xml" + ) + + +def test_tag_ref_with_additional_folder_and_custom_xml_name(): + pkg_info = { + "url": "https://github.com/example/some-release.git", + "tag": "release/rolling/some_pkg/1.0.0-1", + "additional_folder": "some_pkg", + "package_xml_name": "package.xml", + } + + url = _distro()._construct_raw_url_github(pkg_info) + + assert url == ( + "https://raw.githubusercontent.com/example/some-release/" + "refs/tags/release/rolling/some_pkg/1.0.0-1/some_pkg/package.xml" + ) diff --git a/vinca/test_snapshot_metadata.py b/vinca/test_snapshot_metadata.py index ca7eb56..e616572 100644 --- a/vinca/test_snapshot_metadata.py +++ b/vinca/test_snapshot_metadata.py @@ -61,9 +61,11 @@ def make_snapshot_distro(monkeypatch): distro._distro = Mock() snapshot_xml_by_url = { "https://raw.githubusercontent.com/example/snapshot-package-release/" - "release/rolling/snapshot_package/1.0.0-1/package.xml": (SNAPSHOT_PACKAGE_XML), + "refs/tags/release/rolling/snapshot_package/1.0.0-1/package.xml": ( + SNAPSHOT_PACKAGE_XML + ), "https://raw.githubusercontent.com/example/snapshot-dependency-release/" - "release/rolling/snapshot_dependency/1.0.0-1/package.xml": ( + "refs/tags/release/rolling/snapshot_dependency/1.0.0-1/package.xml": ( SNAPSHOT_DEPENDENCY_XML ), }