Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: test

on:
pull_request:
Expand All @@ -10,7 +10,7 @@ concurrency:
cancel-in-progress: true

jobs:
build:
test:
name: 👷 Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
Expand Down
8 changes: 3 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32953,18 +32953,16 @@ async function getVersion() {
* @example "v0.1.0"
*/
async function getLatestVersion() {
const releaseResponse = await octokit.rest.repos.listReleases({
const releaseResponse = await octokit.rest.repos.getLatestRelease({
owner: "spacelift-io",
repo: "spacectl",
});
const releaseList = releaseResponse.data;
if (!releaseList?.length) {
if (!releaseResponse.data?.tag_name) {
const errMsg = "Could not find any releases for Spacectl. GitHub outage perhaps? https://www.githubstatus.com/";
core.setFailed(errMsg);
throw new Error(errMsg);
}
const filteredReleases = releaseList.filter((release) => !release.draft && !release.prerelease);
return filteredReleases[0].tag_name;
return releaseResponse.data.tag_name;
}
/**
* Copy-pasta of:
Expand Down
9 changes: 3 additions & 6 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,18 @@ async function getVersion(): Promise<string> {
* @example "v0.1.0"
*/
async function getLatestVersion(): Promise<string> {
const releaseResponse = await octokit.rest.repos.listReleases({
const releaseResponse = await octokit.rest.repos.getLatestRelease({
owner: "spacelift-io",
repo: "spacectl",
});
const releaseList = releaseResponse.data;

if (!releaseList?.length) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error handling unreachable due to API 404 exception

Medium Severity

The switch from listReleases to getLatestRelease breaks the error handling for missing releases. The old API returned an empty array when no releases exist, allowing the length check to catch it. The new API throws a 404 exception, meaning the if (!releaseResponse.data?.tag_name) check is never reached. Users now see a raw HTTP 404 error instead of the intended helpful message about GitHub outages.

Additional Locations (1)

Fix in Cursor Fix in Web

if (!releaseResponse.data?.tag_name) {
const errMsg = "Could not find any releases for Spacectl. GitHub outage perhaps? https://www.githubstatus.com/";
core.setFailed(errMsg);
throw new Error(errMsg);
}

const filteredReleases = releaseList.filter((release) => !release.draft && !release.prerelease);

return filteredReleases[0].tag_name;
return releaseResponse.data.tag_name;
}

/**
Expand Down
Loading