Skip to content

Commit 01f5811

Browse files
committed
Pin GitHub REST API version in requests
Previously, the requests would use whatever version of the API is current, exposing the action to immediate breakage if GitHub released a new version of the REST API with relevant changes. GitHub provides the previous API for a minimum of 24 months after a new version is released, so pinning the REST API version used by the action via the `X-GitHub-Api-Version` HTTP header improves the stability of the action and allows the project maintainer to make a controlled migration to the new API version.
1 parent 272dfea commit 01f5811

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

reportsizedeltas/reportsizedeltas.py

+1
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ def raw_http_request(self, url: str, data: bytes | None = None):
630630
"Authorization": "Bearer " + self.token,
631631
# GitHub recommends using user name as User-Agent (https://developer.github.com/v3/#user-agent-required)
632632
"User-Agent": self.repository_name.split("/")[0],
633+
"X-GitHub-Api-Version": "2022-11-28",
633634
}
634635
request = urllib.request.Request(url=url, headers=headers, data=data)
635636

reportsizedeltas/tests/test_reportsizedeltas.py

+1
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ def test_raw_http_request(mocker):
893893
"Accept": "application/vnd.github+json",
894894
"Authorization": "Bearer " + token,
895895
"User-Agent": user_name,
896+
"X-GitHub-Api-Version": "2022-11-28",
896897
},
897898
data=data,
898899
)

0 commit comments

Comments
 (0)