Skip to content

fix: Request next page in github_repository_environments data source - #3717

Open
meridius wants to merge 1 commit into
integrations:mainfrom
meridius:fix/repository-environments-pagination
Open

meridius wants to merge 1 commit into
integrations:mainfrom
meridius:fix/repository-environments-pagination

Conversation

@meridius

@meridius meridius commented Nov 3, 2026 •

Copy link
Copy Markdown

Resolves #2519

(#2519 was auto-closed as stale; the bug is still present on main and 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. The EnvironmentListOptions are created inside the for loop, so the Page set from resp.NextPage is 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 carries rel="next" every time.

After the change?

  • The list options are created once before the loop, so the read follows the Link header to the last page and returns all environments.
  • New unit test Test_dataSourceGithubRepositoryEnvironmentsRead serves two pages from the existing githubApiMock helper. It fails on main (the second request repeats page 1 and gets a 400 from the mock) and passes with the fix.
  • I checked the other for {} pagination loops in github/ 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 test equivalent (go test ./... -skip '^TestAcc'), and golangci-lint run with 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

  • Schema migrations have been created if needed (example) (not needed: no schema change)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features) (no doc change needed)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

👋 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.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: when using github_repository_environments as a data source with over 30 environments in a repo the plugin crashes

1 participant