Skip to content

feat: the notification of a failed installation says why the GitHub API gave no download URL, such as its rate limit or a refused token - #2202

Merged
lagergren merged 3 commits into
redhat-developer:mainfrom
lagergren:feat/installer-rate-limit-in-notification
Nov 25, 2026
Merged

lagergren merged 3 commits into
redhat-developer:mainfrom
lagergren:feat/installer-rate-limit-in-notification

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Part of #2188 (part 2: the rate-limit message in the notification of a failed download). Part 1, a GitHub token from the IDE, is still open.

What

When the GitHub API's rate limit stops a github download whose installer has no fallback url, the installation fails. The console says why: when the limit resets, and that a token raises it. The notification didn't. It said "Unable to retrieve the download URL for your platform … define a valid url or github.asset", which is wrong in that case.

Change

  • Reporter: a new default no-op method, addFailureReason(String). It's backward compatible.
  • GitHubAssetFetcher.fetchReleasesJson: collects the messages it already explains in the console, and reports them only when the releases can't be loaded. These are the rate limit, and a token GitHub refuses: expired or bad (401), not authorized by SAML single sign-on, missing permissions, a generic 403, or a repository not found (404).
    • If the retry without the refused token loads the releases but no asset matches, the notification keeps today's platform message.
    • A 404 without the token, after one with it, isn't repeated.
  • DownloadTask:
    • It collects the reasons per lookup, with a private Reporter record, because the fetchers are shared per repository.
    • When there's no URL and there are reasons, it adds them to the notification, HTML-escaped. It then skips the platform message, in the console too, since the fetcher has already printed and logged the explanation.
    • The behaviour with a fallback url is unchanged.
  • No message ever contains the token.
  • Docs: docs/UserDefinedLanguageServerTemplate.md says that the notification now gives the reason too.

#2195 changes the same downloadUrl == null block of DownloadTask. The new if sits before it, so whichever merges later is rebased trivially.

Not in this PR:

  • The single sign-on link shows as escaped text, not as a link.
  • If the retry without the token fails for an unexplained reason, such as HTTP 500, only the token's explanation is in the notification. The 500 is in the console.

Tests

Six new tests in GitHubDownloadTaskTest, with the LocalHttpServer fake of the GitHub API. They capture the real notification through ServerInstallerManager.install and Notifications.TOPIC.

  • The rate limit without url: the notification has the rate-limit message.
  • A fallback url: the same success as before, with no rate-limit text.
  • 401, then the rate limit: both messages, and no token.
  • Single sign-on whose link has &, then 404: HTML-escaped.
  • 404, then 404: said once.
  • A refused token, then releases without the asset: the platform message, as before.

Red-green:

  • Without the change, the four notification tests fail, because they get the platform message. The two guard tests pass both ways.
  • Removing the 404 dedupe, or reporting the refusal before the retry failed, fails exactly the matching test.
  • With the change, all pass, also headless.

The installation.* tests pass on IC 2024.2, 2025.3 and IU 2026.3: 192 tests each, with 0 failures or skipped.

Behaviour change

Before After
A github download without url that the rate limit, a refused token or a missing repository stopped fails with a notification that asks for a valid url or github.asset The notification says why, as the console does. For example: "GitHub API rate limit reached: 60 requests an hour (HTTP 403). It resets at 15:35:07 (local time). Setting the environment variable GITHUB_TOKEN of the IDE to a GitHub token raises the limit to 5,000 requests an hour."

…PI gave no download URL, such as its rate limit or a refused token

When the rate limit of the GitHub API stopped a `github` download whose installer has no fallback
`url`, the notification of the failed installation asked for a `url` or a `github.asset` which
matches the platform. It now says what the console says: the rate limit, when it resets, and that a
GitHub token raises it. The other errors of the GitHub API that the console explains reach it too:
a token which GitHub refused, as an invalid or expired one, one which SAML single sign-on doesn't
authorize, with the link which authorizes it, or one which lacks a permission, and a repository
which was not found or is private.

A download with a fallback `url` uses it as before, without a failure notification, and the
notification of releases which have no asset for the platform is unchanged.

The GitHub asset fetcher reports these messages through a new default method of Reporter,
addFailureReason, only when the releases can't be loaded; the download task collects them for its
own lookup, and the notification gets them HTML-escaped. They never have the token.

Part of redhat-developer#2188
…hy the GitHub API gave no URL

It says when the rate limit resets and that a token raises it, that GitHub refused the token before
the rate limit, and the link of single sign-on HTML-escaped. It says once that a repository was not
found. It is unchanged for a download which falls back to its url, and for releases without an asset
for the platform after a refused token.

Part of redhat-developer#2188
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the enhancement New feature or request label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Failed server installations now show relevant GitHub error reasons, such as rate limits or repository issues, when no download is available.
    • Failure details remain readable when GitHub rejects a token and an anonymous retry also fails.
    • Successful URL fallback behavior remains unchanged.
  • Documentation
    • Updated the GitHub API rate-limit guidance to explain that failure reasons appear in installation notifications.

GitHub asset lookup now collects selected API failure reasons. When no download URL is available, the installer displays escaped reasons in the failure notification. Tests cover notification content and fallback behavior.

Changes: GitHub download notifications

Layer / File(s) Summary
Capture GitHub API failure reasons
src/main/java/com/redhat/devtools/lsp4ij/installation/download/Reporter.java, src/main/java/com/redhat/devtools/lsp4ij/installation/download/GitHubAssetFetcher.java
Reporter accepts failure reasons. GitHubAssetFetcher reports selected API errors, including token refusal and qualifying non-200 responses.
Pass failure reasons to installation notifications
src/main/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/DownloadTask.java, src/test/java/com/redhat/devtools/lsp4ij/installation/download/GitHubDownloadTaskTest.java, docs/UserDefinedLanguageServerTemplate.md
DownloadTask carries collected reasons with the selected URL and displays escaped reasons when no URL is available. Tests cover notification content, ordering, escaping, and fallback behavior. The documentation describes the notification.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DownloadTask
  participant GitHubAssetFetcher
  participant InstallerContext
  DownloadTask->>GitHubAssetFetcher: Fetch releases with failure-reason reporter
  GitHubAssetFetcher->>DownloadTask: Report collected API failure reasons
  DownloadTask->>InstallerContext: Display escaped reasons when no URL is available
Loading

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to 42e6c

This change adds clearer GitHub download failure explanations to installer notifications. It leaves fallback URL behavior unchanged and escapes the reason text. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the failed-installation notification now states why the GitHub API gave no download URL (rate limit or refused token). The raw summary and objectives confirm DownloadT…
Description check Passed The description explains the problem, the change in Reporter, GitHubAssetFetcher, and DownloadTask, the docs update, the tests, and the behaviour change. It matches the changeset in detail.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the failed-installation notification now states why the GitHub API gave no download URL (rate limit or refused token). The raw summary and objectives confirm DownloadTask, GitHubAssetFetcher, and Reporter changes that implement this. The title is long (135 characters), but it is still on topic.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 003513c1-2523-418c-b575-145c51b042cc
Commits

Reviewing files that changed from the base of the PR and between 1cd25d7 and 42e6cfc.

Files selected for processing: 4

  • docs/UserDefinedLanguageServerTemplate.md
  • src/main/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/DownloadTask.java
  • src/main/java/com/redhat/devtools/lsp4ij/installation/download/GitHubAssetFetcher.java
  • src/test/java/com/redhat/devtools/lsp4ij/installation/download/GitHubDownloadTaskTest.java
Files skipped from review as they are similar to previous changes: 1

  • docs/UserDefinedLanguageServerTemplate.md

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.08%. Comparing base (6f3b972) to head (42e6cfc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ij/installation/definition/tasks/DownloadTask.java 75.00% 5 Missing ⚠️
...p4ij/installation/download/GitHubAssetFetcher.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2202      +/-   ##
==========================================
+ Coverage   55.06%   55.08%   +0.02%     
==========================================
  Files         838      839       +1     
  Lines       35599    35624      +25     
  Branches     7346     5577    -1769     
==========================================
+ Hits        19601    19622      +21     
+ Misses      13147    13142       -5     
- Partials     2851     2860       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…imit-in-notification

# Conflicts:
#	src/main/java/com/redhat/devtools/lsp4ij/installation/definition/tasks/DownloadTask.java
#	src/test/java/com/redhat/devtools/lsp4ij/installation/download/GitHubDownloadTaskTest.java
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit 5321d6b into redhat-developer:main Nov 25, 2026
9 checks passed
lagergren added a commit that referenced this pull request Nov 25, 2026
…, or else of the IDE's GitHub account, when GITHUB_TOKEN and GH_TOKEN aren't set (#2230)

Fixes #2188 (part 1, a GitHub token from the IDE). Part 2 was #2202.

## What

A `github` download sent a token only from `GITHUB_TOKEN` or `GH_TOKEN`.
An IDE started from the Windows Start menu or a Linux desktop launcher
doesn't see a token exported in a shell profile, so it stayed at the
GitHub API's 60 requests an hour. An IDE started from the macOS Dock
does read the login shell's environment. The rate-limit message only
suggested `GITHUB_TOKEN`.

## Change

**Precedence** (`GitHubAssetFetcher.findToken`). A blank value falls
through to the next source, and a source that fails is logged and
skipped.
1. `GITHUB_TOKEN`, then `GH_TOKEN`, as before. The environment overrides
stored configuration, as with the GitHub CLI.
2. **The LSP4IJ setting:** a GitHub token in *Settings | Languages &
Frameworks | Language Servers (LSP4IJ)*.
3. **The IDE's GitHub account:** the first github.com account in
*Settings | Version Control | GitHub*.
4. Otherwise no token, as before.

**The setting:**
- `GitHubTokenSettings` keeps it for the whole IDE in the Password Safe,
under `generateServiceName("LSP4IJ", "GitHub token")`, never in XML.
- The UI is `GitHubTokenField`, a password field with a help line.
- The Password Safe is read and written off the EDT; on 2026.3 it is
`@RequiresBackgroundThread`. An empty field removes the stored token.

**The GitHub account:**
- It's read through an optional dependency on the bundled GitHub plugin:
`plugin-github.xml`, with `org.jetbrains.plugins.github` added to
`platformBundledPlugins`.
- Only the Kotlin class `GitHubPluginAccountTokenProvider` refers to
GitHub-plugin classes, so without the plugin the source is simply
absent.
- Only accounts whose server's API URL is the download's are used: a
GitHub Enterprise token never goes to github.com.
- The token is read with `GHAccountManager.findCredentials` in
`runBlockingCancellable`, under the installer's progress.

**Messages:** a token is named by its source, e.g. "the token of the
LSP4IJ settings" or "the token of the IDE's GitHub account <login>". A
refused token from any source is retried without it, and the
notification says why, as for the environment variable since #2202. The
rate-limit hint now names the setting first. The tests check that the
token appears in neither the console, the log, nor the notification.

**Docs:** a "GitHub token" section in
`docs/UserDefinedLanguageServerTemplate.md`. It covers the three sources
and their order, the setting (with a screenshot), what the
failed-install notification says, and that a token doesn't make a
private repository's assets downloadable. The asset download sends no
token.

**API note:**
- `GHAccountManager` is public on 2024.2 and 2025.3, but
`@ApiStatus.Internal` on 2026.3, where the GitHub plugin has no public
way to read an account's token. Its alternatives there are internal too,
require the EDT, or are deprecated.
- The plugin verifier says Compatible on 2024.2 and 2026.3. It reports
one experimental usage on 2024.2 (`runBlockingCancellable`) and one
internal usage on 2026.3 (`GHAccountManager`, 4 references). The
deprecated-usage counts are unchanged.

Not in this PR:
- **Account choice:** with several github.com accounts, the first in the
settings order is used, not a project's default. `GHAccountsUtil`
requires the EDT, and the fetcher has no project.
- **Notification screenshot:** it couldn't be rendered offscreen, so it
will be added from a running IDE. A TODO in the docs marks its place.

## Tests

- `GitHubAssetFetcherTest`: precedence, fall-through, refusal and retry,
and naming of the source.
- `GitHubDownloadTaskTest`: the notification and the log never show the
token.
- `GitHubPluginAccountTokenProviderTest`: a real integration test with
github.com and GitHub Enterprise accounts, through `GHAccountManager`
and the test application's in-memory Password Safe.
- `GitHubTokenFieldTest`: the field stores the token in the Password
Safe, loads it back, and an empty field removes it.

Every wait uses a future with a bound, and there are no fixed sleeps.

Red-green, by mutation: an environment-only lookup gives 18 failures,
the account before the setting gives 3, and the setting before the
environment gives 1.

`installation.*` and `settings.*` pass headless on IC 2024.2, 2025.3 and
IU 2026.3: 310 tests each, 0 failures. The full suite passes on 2024.2
and IU 2026.3: 2,487 tests, 0 failures, with the 7 skipped tests that
were already disabled.

## Behaviour change

| Before | After |
|---|---|
| A `github` download sent a token only from `GITHUB_TOKEN`/`GH_TOKEN`,
and the rate-limit message suggested only `GITHUB_TOKEN` | Without those
variables, it sends the token of the LSP4IJ settings (Password Safe), or
else of the IDE's first github.com account. The console, log and
notification name the source, a refused token is retried without it, and
the rate-limit message names the setting |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant