Skip to content

Rate limit is not being stored correctly in framework #16

Description

@r-wilkins

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions