Skip to content

Installers: send an optional GitHub token, so that GitHub downloads don't stop at the API's 60 calls an hour #2142

Closed

Description

@lagergren

What

A download task with a github source finds the asset through the GitHub REST API. GitHubAssetFetcher requests https://api.github.com/repos/<owner>/<repo>/releases?per_page=100, with no Authorization header, and picks the newest matching release. The download of the asset itself, from github.com/…/releases/download/…, isn't an API call.

Without a token, GitHub allows 60 API calls an hour per IP address. So:

  • Shared IP addresses run out quickly. All the IDEs behind one address share the 60: a corporate network, a VPN, CI runners. A test that installs the bundled servers for real uses about 14 calls a run, so four runs in an hour use them up.
  • Some installers can't install at all then. On HTTP 403, LSP4IJ prints "GitHub API returned HTTP 403" and falls back to the url of the download, if it has one. Of the 15 bundled installers that download from GitHub, 9 have no url: codelldb, ada_language_server, clojure-lsp, cpp_ls, docker-language-server, erlang-ls, harper-ls, luau-lsp and wgsl-analyzer. They can't install until the limit resets, and the message doesn't say why or when that is.

With a token, the limit is 5,000 calls an hour.

Suggestion

  • Send a token when there is one: Authorization: Bearer <token>, only to api.github.com, from the environment variable GITHUB_TOKEN (or GH_TOKEN, as the gh CLI reads). The token must never be printed in the installer console or the log.
  • Maybe also from the IDE: a setting kept in IntelliJ's Password Safe, or the account of IntelliJ's GitHub plugin when it's installed, as an optional dependency.
  • Say when the limit is the cause: on 403 or 429 with X-RateLimit-Remaining: 0, print that the GitHub API rate limit is reached and when it resets (X-RateLimit-Reset), and that a token raises it.

Notes

  • Without a token, nothing changes.
  • Found during the live test of the bundled installers for 0.30.2, which ran out of the 60 calls after a few runs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinstall

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions