Skip to content

ci: retry transient Go module-server errors, and pin the security tools - #635

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/633-go-module-retry
Oct 21, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/633-go-module-retry

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Fixes #633.

The problem

Go doesn't retry a module fetch. One HTTP/2 stream error … INTERNAL_ERROR from proxy.golang.org or sum.golang.org failed five correct PRs this month (#582, #631, #622, #614, #632) before anything compiled. Each module that failed had just been bumped on main. The Security Scan failures came from uncached go install …@latest.

.github/scripts/go-retry.sh

go result Verdict
success done
stream INTERNAL_ERROR, 5xx, timeout, reset 🔁 retried with backoff (3 attempts), each retry printed
missing module / any other error ❌ fails on the first attempt
checksum mismatch / SECURITY ERROR ❌ never retried, checked first even beside a transient-looking line, so a corrupted download can't be retried until a lucky attempt hides it
still transient after 3 ❌ fails: a build can't go ahead without its modules

Wiring

  • All 18 jobs that set up Go, across ci.yml, security.yml, release.yml and live-aws.yml, fetch modules through it as the step right after setup-go. security.yml's bare go mod download is replaced.
  • gosec v2.29.0, govulncheck v1.9.0 and go-licenses v1.6.0 are pinned, not @latest, and installed through the retry. Under @latest, govulncheck had already moved from v1.8.0 with no commit. A security gate that can change its verdict on an unchanged tree isn't a gate.
  • The MinIO and substrate installs go through it too.

Tests

  • TestGoRetryScriptRetriesOnlyTransientModuleServerErrors runs the real script against a stub go and checks the number of attempts as well as the exit status. Removing the checksum guard, retrying everything, and never retrying each fail exactly the cases they should.
  • TestEveryGoJobFetchesModulesThroughTheRetry walks every workflow: a retry download after setup-go with no go before it, no bare go install, and no @latest. Floor of 15 Go jobs.
Mutation Fails at
test job's download step deleted ci.yml job "test" runs go in step "Build" before modules are fetched
govulncheck@latest back names the step and the line
bare go install for substrate names the job and step
go build added before the download (live-aws) names it

Against real Go

Using a local proxy that answers 502 to the first two requests and forwards the rest to proxy.golang.org, with an empty GOMODCACHE:

go: golang.org/x/[email protected]: reading http://127.0.0.1:18765/…/v0.3.8.info: 502 Bad Gateway
::warning::… transient module-server error on attempt 1 of 3; retrying in 1s.
go: … 502 Bad Gateway
::warning::… transient module-server error on attempt 2 of 3; retrying in 2s.
exit=0, [email protected] in the cache

A nonexistent v0.99.99 returns 404 Not Found and fails in 2 s with no retry. Pinned govulncheck v1.9.0 reports no vulnerabilities, and go-licenses v1.6.0 passes.

🤖 Generated with Claude Code

…ls (#633)

Go does not retry a module fetch. A single HTTP/2 stream error from
proxy.golang.org or sum.golang.org failed five correct PRs in October
(#582, #631, #622, #614, #632) before anything compiled. Each module that
failed had just been bumped on main, and the Security Scan failures came
from uncached @latest tool installs.

.github/scripts/go-retry.sh runs a go command and splits failures three
ways. A transient answer (stream INTERNAL_ERROR, 5xx, timeout, reset) is
retried with backoff, and each retry is printed. A missing module, or any
other error, fails on the first attempt. A checksum mismatch / SECURITY
ERROR is checked first and never retried, even beside a transient-looking
line, so a corrupted download can't be retried until a lucky attempt hides
it. Still transient after three attempts is a failure: a build can't
proceed without its modules.

Every job that sets up Go (18 across ci.yml, security.yml, release.yml and
live-aws.yml) fetches modules through it as the step after setup-go.
security.yml's existing bare 'go mod download' is replaced. gosec,
govulncheck and go-licenses are pinned (v2.29.0, v1.9.0, v1.6.0) rather
than @latest and installed through it; govulncheck had already moved from
v1.8.0 under @latest with no commit. The MinIO and substrate installs go
through it too.

Tests:
- TestGoRetryScriptRetriesOnlyTransientModuleServerErrors runs the real
  script against a stub go, asserting the number of attempts as well as
  the exit status. Removing the checksum guard, retrying everything, and
  never retrying each fail the cases they should.
- TestEveryGoJobFetchesModulesThroughTheRetry walks every workflow: a
  retry download after setup-go with no go before it, no bare go install,
  no @latest. Floor of 15 Go jobs. Deleting a job's download step, adding
  @latest back, a bare go install, and a go build before the download each
  fail naming the job and step.

Against real go, with a local proxy that 502s the first two requests into
an empty GOMODCACHE: two visible retries, then success. A nonexistent
version 404s and fails in 2s with no retry. Pinned govulncheck v1.9.0
reports no vulnerabilities, and go-licenses v1.6.0 passes.
@scttfrdmn
scttfrdmn merged commit 3290937 into main Oct 21, 2026
56 checks passed
@scttfrdmn
scttfrdmn deleted the fix/633-go-module-retry branch October 21, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI fails on transient Go module server errors (proxy.golang.org / sum.golang.org INTERNAL_ERROR); retry them

1 participant