Repository navigation
Conversation
The list options were recreated on every loop iteration, so the page set from resp.NextPage was discarded and page 1 was requested forever. Repositories with more than 30 environments made the read loop until the context deadline. Declare the options once before the loop and add a unit test that serves two pages from a mock API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
This branch has not been deployed
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.
Resolves #2519
(#2519 was auto-closed as stale; the bug is still present on
mainand in v6.13.0.)Before the change?
data "github_repository_environments"on a repository with more than 30 environments (the API's default page size) never finishes. TheEnvironmentListOptionsare created inside theforloop, so thePageset fromresp.NextPageis thrown away and page 1 is requested again and again until Terraform's context deadline (Error: context deadline exceeded). We hit this on a repository with 33 environments; the page 1 response carriesrel="next"every time.After the change?
Linkheader to the last page and returns all environments.Test_dataSourceGithubRepositoryEnvironmentsReadserves two pages from the existinggithubApiMockhelper. It fails onmain(the second request repeats page 1 and gets a 400 from the mock) and passes with the fix.for {}pagination loops ingithub/for the same pattern; this data source is the only one that recreates its options inside the loop.Verified locally:
go build ./...,go vet ./github/...,make testequivalent (go test ./... -skip '^TestAcc'), andgolangci-lint runwith both the default and the merged strict config on new code: all clean. I did not run the acceptance tests.AI disclosure: the fix, the test and this description were drafted with Claude Code.
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!
🤖 Generated with Claude Code