fix: retry and verify the Nix archive download - #7
Merged
Conversation
nix-quick-install-action pipes its download straight into tar, so a truncated release asset cannot be retried: curl's own --retry cannot help once a short body has already reached tar. The job then dies with "zstd: unexpected end of file" before any project tool runs, and the reported failure names the caller's job -- gofmt, lint -- rather than the download that actually failed. Fetch the archive to a file first, three bounded attempts with a growing wait and an integrity check on each, then hand the verified copy to nix-quick-install-action through its nix_archives_url input. A body that is short but well-formed at the transfer level is the case only the integrity check can catch, and it now drives a retry instead of a job failure. A download that never arrives intact fails with a message naming the URL. Only a 404 skips the retry: it means nix-version is not a version the pinned release ships, while a 5xx or an expired asset redirect is exactly the transient class the retry exists for. --speed-limit/--speed-time bound a stalled body, so the retry is bounded in wall time and not just in attempts. The pre-fetch has to build the same URL as the pinned action, so the Nix version becomes an explicit input (nix-version, defaulting to the pinned release's own default) passed to both sides, and the release tag is carried next to each pin. Both actions install Nix, so both carry the pre-fetch, and the tests fail if a pin drifts from its release tag or if a manifest reaches the script by a path that does not resolve. The tests run on a bare runner with no Nix, so they still report when the Nix install itself is broken. Refs: InoBram/inobramxd#488
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What fails today
nix-quick-install-actionpipes its download straight intotar:When GitHub serves a truncated release asset, the short body has already
reached
tar, socurl --retrycannot help. The job dies with:Every later step reports
outcome=skipped, so the reported failure names thecaller's job —
gofmt,lint— and points at the pull request, although thepull request is not the cause. Reported downstream as InoBram/inobramxd#488.
What this does
Fetch the same archive to a file first, then hand the verified copy to
nix-quick-install-actionthrough itsnix_archives_urlinput.A body that is short but well-formed at the transfer level is the case only
the integrity check can catch; it now drives a retry, not a job failure.
not the extraction.
nix-versionis not a version thepinned release ships. A 5xx or an expired asset redirect is the transient
class the retry exists for.
--speed-limit/--speed-timebound a stalled body, so the retry is boundedin wall time and not only in attempts.
The pre-fetch has to build the same URL as the pinned action, so the Nix
version becomes an explicit
nix-versioninput (default2.29.2, the pinnedrelease's own default) passed to both sides. Both actions install Nix, so both
carry the pre-fetch.
Tests
tests/prefetch-nix-archive.test.sh— 26 assertions, driven by a local serverthat reproduces each failure mode. It installs no Nix, so it still reports when
the Nix install itself is broken.
Covered: a healthy download; a silently truncated body (retried, not accepted);
an always-truncated body (fails, message names the URL and the attempt count,
leaves no archive behind); a 404 (one request, no retry); a 5xx (retried to
exhaustion); the reported output path; and two static guards — each manifest's
pin matches the release tag it pre-fetches, and the path each manifest uses
resolves to the script.
The
nix-versionjob installs a non-default Nix (2.28.5) and assertsnix --versionreports it, which proves the pre-fetched archive is theinstalled one.
After merge
This needs a release for
@v1callers to get it:docs/releasing.md.