Improve error messages on GitHub API errors (#518)
Some checks failed
CodeQL / Analyze (TypeScript) (push) Failing after 3s
test / test-default-version (ubuntu-latest) (push) Failing after 2s
test / test-specific-version (0.3) (push) Failing after 2s
test / test-specific-version (0.3.2) (push) Failing after 2s
test / test-specific-version (0.3.x) (push) Failing after 1s
test / test-semver-range (ubuntu-latest) (push) Failing after 1s
test / test-pep440-version (push) Failing after 1s
test / test-malformed-pyproject-file-fallback (push) Failing after 1s
test / test-uv-file-version (push) Failing after 1s
test / test-version-file-hash-version (push) Failing after 1s
test / test-checksum (map[checksum:4d9279ad5ca596b1e2d703901d508430eb07564dc4d8837de9e2fca9c90f8ecd os:ubuntu-latest]) (push) Failing after 1s
test / test-uvx (push) Failing after 1s
test / test-tool-install (ubuntu-latest) (push) Failing after 1s
test / test-activate-environment (ubuntu-latest) (push) Failing after 1s
test / test-setup-cache (false, ubuntu-latest) (push) Failing after 1s
test / test-setup-cache (true, ubuntu-latest) (push) Failing after 1s
test / test-musl (push) Failing after 5s
test / test-restore-cache-dependency-glob (push) Has been skipped
test / test-setup-cache-dependency-glob (push) Failing after 1s
test / test-custom-manifest-file (push) Failing after 1s
test / test-cache-local (map[expected-cache-dir:/home/runner/work/_temp/setup-uv-cache os:ubuntu-latest]) (push) Failing after 2s
test / test-absolute-path (push) Failing after 2s
test / lint (push) Failing after 6m57s
test / test-specific-version (0.3.0) (push) Failing after 6m57s
test / test-specific-version (>=0.3.0) (push) Failing after 6m56s
test / test-pyproject-file-version (push) Failing after 6m55s
test / test-version-file-version (push) Failing after 6m53s
test / test-with-explicit-token (push) Failing after 6m52s
test / test-python-version (ubuntu-latest) (push) Failing after 6m51s
test / test-setup-cache-requirements-txt (push) Failing after 6m48s
test / test-setup-cache (auto, ubuntu-latest) (push) Failing after 6m49s
test / test-no-python-version (push) Failing after 6m47s
test / test-relative-path (push) Failing after 6m45s
Update known versions / build (push) Has been cancelled
test / test-tilde-expansion-cache-local-path (push) Has been cancelled
Release Drafter / ✏️ Draft release (push) Has been cancelled
test / test-default-version (macos-14) (push) Has been cancelled
test / test-default-version (macos-latest) (push) Has been cancelled
test / test-default-version (windows-latest) (push) Has been cancelled
test / test-semver-range (selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-checksum (map[checksum:a70cbfbf3bb5c08b2f84963b4f12c94e08fbb2468ba418a3bfe1066fbe9e7218 os:macos-latest]) (push) Has been cancelled
test / test-tool-install (macos-14) (push) Has been cancelled
test / test-tool-install (macos-latest) (push) Has been cancelled
test / test-tool-install (windows-latest) (push) Has been cancelled
test / test-setup-cache (false, windows-latest) (push) Has been cancelled
test / test-setup-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (true, windows-latest) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:/home/ubuntu/.cache/uv os:selfhosted-ubuntu-arm64]) (push) Has been cancelled
test / test-cache-local (map[expected-cache-dir:D:\a\_temp\setup-uv-cache os:windows-latest]) (push) Has been cancelled
test / test-setup-cache-local (push) Has been cancelled
test / test-tilde-expansion-cache-dependency-glob (push) Has been cancelled
test / test-tilde-expansion-tool-dirs (push) Has been cancelled
test / test-python-version (macos-latest) (push) Has been cancelled
test / test-python-version (windows-latest) (push) Has been cancelled
test / test-activate-environment (macos-latest) (push) Has been cancelled
test / test-activate-environment (windows-latest) (push) Has been cancelled
test / test-setup-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-setup-cache (auto, windows-latest) (push) Has been cancelled
test / test-setup-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (auto, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (auto, windows-latest) (push) Has been cancelled
test / test-restore-cache (false, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (false, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (false, windows-latest) (push) Has been cancelled
test / test-restore-cache (true, selfhosted-ubuntu-arm64) (push) Has been cancelled
test / test-restore-cache (true, ubuntu-latest) (push) Has been cancelled
test / test-restore-cache (true, windows-latest) (push) Has been cancelled
test / test-restore-cache-requirements-txt (push) Has been cancelled
test / test-restore-cache-local (push) Has been cancelled
test / cleanup-tilde-expansion-tests (push) Has been cancelled
test / all-tests-passed (push) Has been cancelled

Fixes: #513
This commit is contained in:
Kevin Stillhammer
2025-08-12 22:50:05 +02:00
committed by GitHub
parent e5d42a2b46
commit d9e0f98d3f
4 changed files with 50 additions and 14 deletions

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}

16
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,16 @@
{
"editor.codeActionsOnSave": {
"source.action.useSortedAttributes.biome": "explicit",
"source.action.useSortedKeys.biome": "explicit",
"source.fixAll.biome": "explicit"
},
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"explorer.excludeGitIgnore": false,
"search.defaultViewMode": "list",
"search.exclude": {
"**/node_modules": true
},
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "node_modules/typescript/lib"
}

19
dist/setup/index.js generated vendored
View File

@ -126195,7 +126195,11 @@ async function getReleaseTagNames(octokit) {
owner: constants_1.OWNER,
repo: constants_1.REPO,
});
return response.map((release) => release.tag_name);
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 releaseTagNames;
}
async function getLatestVersion(githubToken) {
core.debug("Getting latest version...");
@ -126207,12 +126211,15 @@ async function getLatestVersion(githubToken) {
latestRelease = await getLatestRelease(octokit);
}
catch (err) {
core.info("No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.");
if (err instanceof Error) {
core.debug(err.message);
if (err.message.includes("Bad credentials")) {
core.info("No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.");
const octokit = new octokit_1.Octokit();
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;
}
const octokit = new octokit_1.Octokit();
latestRelease = await getLatestRelease(octokit);
}
if (!latestRelease) {
throw new Error("Could not determine latest release.");

View File

@ -184,7 +184,13 @@ async function getReleaseTagNames(
owner: OWNER,
repo: REPO,
});
return response.map((release) => release.tag_name);
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 releaseTagNames;
}
async function getLatestVersion(githubToken: string) {
@ -197,14 +203,18 @@ async function getLatestVersion(githubToken: string) {
try {
latestRelease = await getLatestRelease(octokit);
} catch (err) {
core.info(
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
);
if (err instanceof Error) {
core.debug(err.message);
if ((err as Error).message.includes("Bad credentials")) {
core.info(
"No (valid) GitHub token provided. Falling back to anonymous. Requests might be rate limited.",
);
const octokit = new Octokit();
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;
}
const octokit = new Octokit();
latestRelease = await getLatestRelease(octokit);
}
if (!latestRelease) {