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

Rate limit is not being stored correctly in framework #16

Open
r-wilkins opened this issue Mar 8, 2024 · 0 comments
Open

Rate limit is not being stored correctly in framework #16

r-wilkins opened this issue Mar 8, 2024 · 0 comments

Comments

@r-wilkins
Copy link

We noticed our Rate limit was showing as 4 of 5 when starting to test out using this framework. Upon further inspection we noticed that when referring to the API Headers in certain modules, it was only capturing the first character in the value due to having [0] at the end. This results in fields that use the variables $rateTotal and $rateRemaining to calculate incorrectly. One very noticable issue was the throttling because it was using just single digit numbers it took longer than expected to do larger scripts due to it sleeping more often.

Expected Behavior

Values should point to the entire value inside the header.
ie
Example from Log Verbose of whofs
VERBOSE: Current FreshService minute rate limit is **500 with 439 calls remaining (12.2% used)**

Example of part of whofs output

Api-Version          : latest=v2; requested=v2
Ratelimiting-Managed : true
Ratelimit-Total      : 500
Ratelimit-Remaining  : 473

Current Behavior

Example from Log Verbose of whofs
VERBOSE: Current FreshService minute rate limit is 5 with 4 calls remaining (1.89% used) .

Example of part of whofs output

Api-Version          : l
Ratelimiting-Managed : t
Ratelimit-Total      : 5
Ratelimit-Remaining  : 4

Possible Solution

Remove [0] from the ends of lines that reference $results.Headers and $results.Headers from the following files to match below:
Invoke-FreshworksRestMethod.ps1 (Lines 193 and 194)

$rateTotal = $results.Headers['X-Ratelimit-Total']
$rateRemaining = $results.Headers['X-Ratelimit-Remaining']

Get-FreshServiceInfo.ps1 (Lines 63 through 66)

'Api-Version'          = $result.Headers['X-Freshservice-Api-Version']
'Ratelimiting-Managed' = $result.Headers['X-Fw-Ratelimiting-Managed']
'Ratelimit-Total'      = $result.Headers['X-Ratelimit-Total']
'Ratelimit-Remaining'  = $result.Headers['X-Ratelimit-Remaining']

Steps to Reproduce (for bugs)

1.Verify API limits for you account by looking at headers of from manually doing webrequest (Ours is 500)
2. Open powershell and connect to your instance
3. Run Type Whofs -verbose
4. Observe Output

Context

Your Environment

  • Module version used: 0.1.4
  • Operating System and PowerShell version:
    Windows 10
    Powershell version 5.1.19041.2673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant