Skip to content

Check version exists on GitHub before downloading#64

Merged
albertodebortoli merged 1 commit intomainfrom
feature/version-existence-check-before-download
Apr 12, 2026
Merged

Check version exists on GitHub before downloading#64
albertodebortoli merged 1 commit intomainfrom
feature/version-existence-check-before-download

Conversation

@albertodebortoli
Copy link
Copy Markdown
Member

Pull Request Title

Check version exists on GitHub before downloading

Description

  • SelfUpdater.performUpdate previously attempted to download a release ZIP without verifying the version exists on GitHub first. When the version was absent (e.g. a typo in .luca-version), the download would silently fetch an HTML 404 page, then unzip would fail, producing a cryptic extractionFailed error.
  • This PR adds a pre-download check against the GitHub Releases API (/releases/tags/{version}). A 404 response now throws a clear versionNotFound error with a message pointing the user to their .luca-version file. Any other response (200, 5xx, network errors) lets the flow proceed unchanged so existing behaviour is unaffected.

Type of Change

  • Feature

How Has This Been Tested?

  • Added / updated unit tests
  • Manually tested locally (describe)

test_updateIfNeeded_versionNotFound_throwsVersionNotFound — verifies a 404 from the GitHub API throws SelfUpdater.SelfUpdaterError.versionNotFound. All 30 SelfUpdaterTests pass.

swift test --filter SelfUpdaterTests

Checklist

  • Swift code builds locally (swift build)
  • Tests pass locally (swift test)
  • Code style / formatting respected
  • Documentation updated (README / comments)

Breaking Changes?

  • No

Additional Notes

Non-404 responses (5xx, network errors) deliberately do not throw — the flow falls through to the download, which will surface its own error if the release truly cannot be reached. This avoids blocking users on transient API failures.

Adds a pre-download API call to the GitHub Releases endpoint for the
specific tag. A 404 response now throws a clear `versionNotFound` error
instead of letting the download silently fetch an HTML page and then
fail with a cryptic `extractionFailed` from unzip.
@albertodebortoli albertodebortoli added this to the 0.15.0 milestone Apr 12, 2026
@albertodebortoli albertodebortoli added the feature New feature or enhancement label Apr 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@albertodebortoli albertodebortoli merged commit 1f3177b into main Apr 12, 2026
3 checks passed
@albertodebortoli albertodebortoli deleted the feature/version-existence-check-before-download branch April 12, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant