Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Ratelimiting? #544

Open
2 tasks done
sultanberisa opened this issue Sep 11, 2023 · 2 comments
Open
2 tasks done

[Bug]: Ratelimiting? #544

sultanberisa opened this issue Sep 11, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@sultanberisa
Copy link

What happened?

I am building an automated packaging workflow using evergreen. At some point, i noticed that my variable which would hold the download url which is dynamically retrieved via evergreen, was null. Upon checking closer i can see that i get ratelimited:

PS C:\NIP_Software\Scripts> $DownloadURL = Get-EvergreenApp -Name $AppName | Where-Object { if (!$_.Architecture -or $_.Architecture -eq "x64") {$true} else {$false} } | Where-Object { if (!$_.Channel -or $_.Channel -eq $sourcechannel) {$true} else {$false} } | Where-Object { if (!$_.Type -or $_.Type -eq $sourcepackagetype) {$true} else {$false} } | Where-Object { if (!$_.Platform -or $_.Platform -eq $sourceplatform) {$true} else {$false} } | Where-Object { if (!$_.Language -or $_.Language -eq $sourcelanguage) {$true} else {$false} } | Select -ExpandProperty URI | Select-Object -First 1
WARNING: Get-GitHubRateLimit: Requests to GitHub are being rate limited.
PS C:\NIP_Software\Scripts> Get-EvergreenApp -Name $appname
WARNING: Get-GitHubRateLimit: Requests to GitHub are being rate limited.

Version     URI
-------     ---
RateLimited https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting


PS C:\NIP_Software\Scripts> $AppName = GitForWindows
GitForWindows : The term 'GitForWindows' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:12
+ $AppName = GitForWindows
+            ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (GitForWindows:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\NIP_Software\Scripts> $Arch = "x64"
PS C:\NIP_Software\Scripts> $AppType = "EXE"
PS C:\NIP_Software\Scripts>
PS C:\NIP_Software\Scripts> $ThisApp = (Get-EvergreenApp $($AppName) | Where-Object {$_.Architecture -eq $($Arch) -and $_.Type -eq $($AppType).ToLower() -and $_.URI -notlike "*PortableGit*"})
WARNING: Get-GitHubRateLimit: Requests to GitHub are being rate limited.
PS C:\NIP_Software\Scripts> #[version]$LatestVersion = $ThisApp.Version
PS C:\NIP_Software\Scripts> $SourceUrl = $ThisApp.URI
PS C:\NIP_Software\Scripts> # Evergreen version returns 3 digit version so obtain 4 digit version from URI
PS C:\NIP_Software\Scripts> [version]$LatestVersion = (((($ThisApp).URI -split "/")[7]) -replace '^v') -replace '.windows'
Cannot convert value "" to type "System.Version". Error: "Versjonsstrengdelen var for kort eller for lang."
At line:1 char:1
+ [version]$LatestVersion = (((($ThisApp).URI -split "/")[7]) -replace  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMetadataException
    + FullyQualifiedErrorId : RuntimeException

How can i avoid this / solve this somehow? If i get ratelimited during a workflow it would be pretty stupid and would require manual action, thus removing the whole point of the "workflow" haha

Version

2309.840

What PowerShell edition/s are you running Evergreen on?

Windows PowerShell

Which operating system/s are you running Evergreen on?

Windows 10+

Have you reviewed the documentation?

Verbose output

PS C:\NIP_Software\Scripts> $DownloadURL = Get-EvergreenApp -Name $AppName | Where-Object { if (!$_.Architecture -or $_.Architecture -eq "x64") {$true} else {$false} } | Where-Object { if (!$_.Channel -or $_.Channel -eq $sourcechannel) {$true} else {$false} } | Where-Object { if (!$_.Type -or $_.Type -eq $sourcepackagetype) {$true} else {$false} } | Where-Object { if (!$_.Platform -or $_.Platform -eq $sourceplatform) {$true} else {$false} } | Where-Object { if (!$_.Language -or $_.Language -eq $sourcelanguage) {$true} else {$false} } | Select -ExpandProperty URI | Select-Object -First 1^C
PS C:\NIP_Software\Scripts> $DownloadURL = Get-EvergreenApp -Name $AppName -Verbose | Where-Object { if (!$_.Architecture -or $_.Architecture -eq "x64") {$true} else {$false} } | Where-Object { if (!$_.Channel -or $_.Channel -eq $sourcechannel) {$true} else {$false} } | Where-Object { if (!$_.Type -or $_.Type -eq $sourcepackagetype) {$true} else {$false} } | Where-Object { if (!$_.Platform -or $_.Platform -eq $sourceplatform) {$true} else {$false} } | Where-Object { if (!$_.Language -or $_.Language -eq $sourcelanguage) {$true} else {$false} } | Select -ExpandProperty URI | Select-Object -First 1
VERBOSE: Function path: C:\Program Files\WindowsPowerShell\Modules\Evergreen\2309.840\Apps\Get-NotepadPlusPlus.ps1
VERBOSE: Function exists: C:\Program Files\WindowsPowerShell\Modules\Evergreen\2309.840\Apps\Get-NotepadPlusPlus.ps1.
VERBOSE: Dot sourcing: C:\Program Files\WindowsPowerShell\Modules\Evergreen\2309.840\Apps\Get-NotepadPlusPlus.ps1.
VERBOSE: Get-FunctionResource: read application resource strings from [C:\Program
Files\WindowsPowerShell\Modules\Evergreen\2309.840\Manifests\NotepadPlusPlus.json]
VERBOSE: Calling: Get-NotepadPlusPlus.
VERBOSE: Get-GitHubRateLimit: Checking for how many requests to the GitHub API we have left.
VERBOSE: GET https://api.github.com/rate_limit with 0-byte payload
VERBOSE: received 465-byte response of content type application/json; charset=utf-8
VERBOSE: Get-GitHubRateLimit: We have 0 requests left to the GitHub API in this window.
VERBOSE: Get-GitHubRateLimit: Rate limit window resets at: 11.09.2023 20:08.
WARNING: Get-GitHubRateLimit: Requests to GitHub are being rate limited.
PS C:\NIP_Software\Scripts>
@sultanberisa sultanberisa added the bug Something isn't working label Sep 11, 2023
@aaronparker
Copy link
Owner

You can authenticate to the GitHub API, and save the authentication token to $Env:GH_TOKEN or $Env:GITHUB_TOKEN. Evergreen will then use the token when querying the API, and you won't be rate limited.

See https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api

@sultanberisa
Copy link
Author

You can authenticate to the GitHub API, and save the authentication token to $Env:GH_TOKEN or $Env:GITHUB_TOKEN. Evergreen will then use the token when querying the API, and you won't be rate limited.

See https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api

Saving my Fine-grained personal access token into $Env:GH_TOKEN or $Env:GITHUB_TOKEN in PowerShell is not working. Still recieving rate limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants