fix: paginate environment and repo variable API calls - #1042
Open
cdav wants to merge 1 commit into
Open
Conversation
GitHub's Actions Variables API returns results paginated with a default page size of 10. Repos or environments with more than 10 variables would only have the first page fetched, causing safe-settings to incorrectly treat the remaining variables as additions on every sync. Switch variables.js and environments.js to use github.paginate() with per_page: 100, and add a || [] guard on the mapper so that environments with zero variables don't inject undefined into the accumulated array.
Author
|
@decyjphr this is ready for review at your convenience |
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
Fixes #1040
GitHub's Actions Variables API returns results paginated with a default page size of 10. Repos or environments with more than 10 variables would only have the first page fetched, causing safe-settings to incorrectly treat the remaining variables as missing on every sync — attempting to re-create them and generating API errors.
Changes
lib/plugins/variables.js: Switchfind()from a singlegithub.request()call togithub.paginate()withper_page: 100, so all repo-level action variables are fetched regardless of count.lib/plugins/environments.js: Switch environment variable fetching fromgithub.request()togithub.paginate()withper_page: 100. Also add a|| []guard on the paginate mapper so environments with zero variables return an empty array rather thanundefined(which would otherwise be concatenated into the result array and cause a downstreamTypeError).Testing
Verified against an org with a repo configured for 12 action variables — all 12 are now fetched and compared correctly on each sync.