From 232c1eca568498016834d8bfa5e5721b6968aa68 Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Tue, 12 Aug 2025 21:13:17 +0200 Subject: [PATCH] Improve error messages on GitHub API errors (#199) Fixes: #198 --- dist/ruff-action/index.js | 5 +++++ src/download/download-version.ts | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/dist/ruff-action/index.js b/dist/ruff-action/index.js index a648b79..dc177f2 100644 --- a/dist/ruff-action/index.js +++ b/dist/ruff-action/index.js @@ -31657,6 +31657,10 @@ async function getReleaseTagNames(octokit) { owner: constants_1.OWNER, repo: constants_1.REPO, }); + const releaseTagNames = response.map((release) => release.tag_name); + if (releaseTagNames.length === 0) { + throw Error("Github API request failed while getting releases. Check the GitHub status page for outages. Try again later."); + } return response.map((release) => release.tag_name); } async function getLatestVersion(githubToken) { @@ -31674,6 +31678,7 @@ async function getLatestVersion(githubToken) { latestRelease = await getLatestRelease(octokit); } else { + core.error("Github API request failed while getting latest release. Check the GitHub status page for outages. Try again later."); throw err; } } diff --git a/src/download/download-version.ts b/src/download/download-version.ts index a2440f0..64f7bbe 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -158,6 +158,12 @@ async function getReleaseTagNames( owner: OWNER, repo: REPO, }); + const releaseTagNames = response.map((release) => release.tag_name); + if (releaseTagNames.length === 0) { + throw Error( + "Github API request failed while getting releases. Check the GitHub status page for outages. Try again later.", + ); + } return response.map((release) => release.tag_name); } @@ -177,6 +183,9 @@ async function getLatestVersion(githubToken: string) { const octokit = new PaginatingOctokit(); latestRelease = await getLatestRelease(octokit); } else { + core.error( + "Github API request failed while getting latest release. Check the GitHub status page for outages. Try again later.", + ); throw err; } }