Repository navigation
fix(api): serve every page of the OpenTofu releases in /tofu/index.json - #3968
Merged
Merged
Conversation
GitHub pages the releases list (30 per page by default), so the proxy cached and served only the newest 30 OpenTofu releases and the executor could not resolve older versions such as 1.6.0 or 1.8.x. The API now follows Link rel="next" (per_page=100 only for GitHub URLs, at most 20 pages, one total deadline, same-origin links only so the token stays on the configured host) and serves all releases as one JSON array. Older executor library versions read it unchanged. If a later page fails, the pages read are merged with the stale cached list and cached for one minute; a first-page failure keeps the stale/503 fallback.
This was referenced Nov 20, 2026
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.
Problem
/tofu/index.jsonproxieshttps://api.github.com/repos/opentofu/opentofu/releasesin a single request. GitHub returns 30 releases per page by default, so the API cached and served only the newest 30, and the executor (which reads this endpoint, not GitHub) could not resolve older versions such as1.6.0or~>1.8.0. Follow-up to terrakube-io/terraform-spring-boot#120 (comment).Change
DownloadReleasesService.downloadAllReleasesfollowsLink: rel="next"and returns all pages as one JSON array. The rules match terraform-spring-boot#120:per_page=100only forapi.github.comand GitHub Enterprise/api/v3/, and only when not already set; mirror URLs (e.g. pre-signed S3/GCS) are requested as configured;TofuJsonControllerserves and caches the combined array, without aLinkheader. Executors on the current library (1.9.1, without Add field job reference in history #120) read it unchanged, so no executor change is needed.tag_name/namewithoutv) and cached for 1 minute instead of the configured TTL. A first-page failure keeps the existing stale/503 fallback.Note: the full list is ~113 releases, ~8 MB of JSON (previously ~2 MB for 30), stored in the cache and stale keys.
Tests
DownloadReleasesServiceTest: multi-page with absolute and relative links, single-page mirror, 403 on page 2 keeps page 1, first-page failure and non-array body throw, cross-origin next link not followed (token not sent), loop, page cap, total deadline across slow pages,per_pagerules,reltoken parsing acrossLinkheaders.IndexTests: complete list cached with the configured TTL; partial list merged with stale and cached for 1 minute.DownloadReleasesServiceTest+IndexTests: 23/23 pass. Live GitHub: 113 releases over 2 pages, complete, includesv1.6.0andv1.8.0.