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

RequestError [HttpError]: API rate limit exceeded #21

Closed
leinardi opened this issue Jan 23, 2023 · 5 comments · Fixed by #22
Closed

RequestError [HttpError]: API rate limit exceeded #21

leinardi opened this issue Jan 23, 2023 · 5 comments · Fixed by #22
Labels

Comments

@leinardi
Copy link

Since last week we are starting to get some API rate limit exceeded errors when using this action.

This is the error:

Run saucelabs/saucectl-run-action@v2
/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:7761
      const error = new requestError.RequestError(toErrorMessage(data), status, {
                    ^

RequestError [HttpError]: API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)
    at /home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:7761:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async selectCompatibleVersion (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:16336:22)
    at async saucectlInstall (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:16351:21)
    at async run (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:16676:10) {
  status: 403,
  response: {
    url: 'https://api.github.com/repos/saucelabs/saucectl/releases',
    status: 403,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Used, X-RateLimit-Resource, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
      connection: 'close',
      'content-length': '276',
      'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 23 Jan 2023 10:33:45 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'Varnish',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-ratelimit-limit': '60',
      'x-ratelimit-remaining': '0',
      'x-ratelimit-reset': '1674471352',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '60',
      'x-xss-protection': '1; mode=block'
    },
    data: {
      message: "API rate limit exceeded for xxx.xxx.xxx.xxx. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)",
      documentation_url: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting'
    }
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/saucelabs/saucectl/releases',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/19.0.4 octokit-core.js/4.0.5 Node.js/16.13.0 (linux; x64)'
    },
    request: { hook: [Function: bound bound register] }
  }
}

The error states that Authenticated requests get a higher rate limit, but I think we are already using authenticated requests or, at least this is how we are starting the Action:

      - name: Run PR Android test
        uses: saucelabs/saucectl-run-action@v2
        with:
          sauce-username: ${{ secrets.SAUCE_USERNAME }}
          sauce-access-key: ${{ secrets.SAUCE_ACCESS_KEY }}
          testing-environment: ''
          select-suite: 'PR_TEST'

Are we doing something wrong? How is it possible that we are already hitting the API limit? And why the error is stating that Authenticated requests get a higher rate limit?

@cameronbrandcoders
Copy link

Can confirm, I am seeing the same thing. One difference, I am authenticating with this action, and am running saucectl in a separate step.

- name: 'Authenticate Saucelabs'
        uses: saucelabs/saucectl-run-action@v2
        with:
          skip-run: true
          sauce-username: ${{ secrets.SAUCELABS_USERNAME }}
          sauce-access-key: ${{ secrets.SAUCELABS_ACCESSKEY }}

then separately later in the action

- name: 'Run The Test'
  env:
    {stuff}
  run: saucectl run --config .sauce/sanity-test.yml --select-suite "$SUITE" --env latest=1 --env environment="$ENVIRONMENT" --env versionnumber="$VERSIONNUMBER" --env repository="$REPOSITORY" --env githubref="$GITHUBREF" --env githubsha="$GITHUBSHA" --env buildnumber="$BUILDNUMBER"

But the outcome is the same, occasionally I am seeing the api limit error.

@FriggaHel FriggaHel linked a pull request Jan 25, 2023 that will close this issue
@FriggaHel
Copy link
Contributor

Hi !

We've updated the action to use GITHUB_TOKEN, so this error is far less likely to happen.
Note: the GITHUB_TOKEN needs to be explicitly provided to the step.
Example here: https://github.com/saucelabs/saucectl-run-action/tree/main#basic

@leinardi
Copy link
Author

Hi @FriggaHel,

after adding the GITHUB_TOKEN the action is now always failing with the error Bad credentials:

Run saucelabs/saucectl-run-action@v2
  with:
    sauce-username: ***
    sauce-access-key: ***
    select-suite: PR_TEST
    saucectl-version: latest
    working-directory: .
    config-file: .sauce/config.yml
    skip-run: false
    showConsoleLog: false
  env:
    ORG_GRADLE_PROJECT_GRADLE_BUILD_CACHE_NODE_USR: ***
    ORG_GRADLE_PROJECT_GRADLE_BUILD_CACHE_NODE_PWD: ***
    JAVA_TOOL_OPTIONS: -Xmx4g
    TERM: dumb
    JAVA_HOME: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.14-101/x64
    JAVA_HOME_11_X64: /opt/hostedtoolcache/Java_Adopt_jdk/11.0.14-101/x64
    GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
    GRADLE_BUILD_ACTION_CACHE_RESTORED: true
    GITHUB_TOKEN: $***
/home/runner/work/_actions/saucelabs/saucectl-run-action/v[2](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:2)/dist/main/index.js:7792
      const error = new requestError.RequestError(toErrorMessage(data), status, {
                    ^

RequestError [HttpError]: Bad credentials
    at /home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:7792:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async selectCompatibleVersion (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:16[3](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:3)78:22)
    at async saucectlInstall (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:16393:21)
    at async run (/home/runner/work/_actions/saucelabs/saucectl-run-action/v2/dist/main/index.js:1672[4](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:4):10) {
  status: 401,
  response: {
    url: 'https://api.github.com/repos/saucelabs/saucectl/releases',
    status: 401,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      connection: 'close',
      'content-length': '80',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Wed, 2[5](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:5) Jan 2023 21:54:01 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=3153[6](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:6)000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '3040:66C0:613[7](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:7)71:C664A5:63D1A4F9',
      'x-ratelimit-limit': '60',
      'x-ratelimit-remaining': '57',
      'x-ratelimit-reset': '16746[8](https://github.com/veeva-oncology-link/link2-android/actions/runs/4010129265/jobs/6886544905#step:8:8)6212',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '3',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Bad credentials',
      documentation_url: 'https://docs.github.com/rest'
    }
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/saucelabs/saucectl/releases',
    headers: {
      accept: 'application/vnd.github.v3+json',
      authorization: 'token [REDACTED]'
    },
    request: { hook: [Function: bound bound register] }
  }
}

Is it referring to the sauce-username and sauce-access-key? I checked and those are correctly defined inside the GitHub Settings. Can you please tell me where should I get the values from, just to be sure that I have the right values?

@FriggaHel
Copy link
Contributor

Hi @leinardi !

My bad, I introduced a typo in the README.md.

Expected env needs to be

env:
  GITHUB_TOKEN: ${{ github.token }}

and not:

env:
  GITHUB_TOKEN: $${{ github.token }}

I will update the doc accordingly.

According to your output, it looks like you replicated my mistake.

env:
[...]
    GITHUB_TOKEN: $***

At this stage this is not an error on Sauce Labs authentication.

@leinardi
Copy link
Author

Hi @FriggaHel, typo fixed, everything seems fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants