You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: use a completion item unresolved when its resolve fails - #1814
When a language server answers completionItem/resolve with an error, such as typescript-language-server's "Cannot read properties of undefined (reading 'file')" in #784, selecting the completion item inserts nothing: the typed prefix stays as it is, and IntelliJ reports the ResponseErrorException as an IDE error. The expensive renderer of the selected item, which is where #784's stack trace comes from, and the item's documentation fail with the same exception.
LSPCompletionProposal.getResolvedCompletionItem() waits for the request with awaitWithCheckCanceled, which rethrows a failed request wrapped in a RuntimeException, and it catches only cancellations. Before 0.20.2 the wait caught the ExecutionException and logged it as an error, which is the IDE error in #784, and the item was then inserted unresolved. 15aa49ae ("perf: Use ProgressIndicatorUtils.awaitWithCheckCanceled", in 0.20.2) removed that catch, so the error now escapes handleInsert before anything is inserted. The request was also sent without a CancellationSupport, so the server's Error reporting setting didn't apply to it, as it does to other LSP requests.
LSPCompletionProposal.getResolvedCompletionItemFuture(): the completionItem/resolve request now goes through a CancellationSupport with its language server, like codeLens/resolve, inlayHint/resolve and documentLink/resolve. A ResponseErrorException is reported as the server's Error reporting setting says (a notification by default, the log, or nothing), and the request completes with null. Every caller already takes null as "not resolved", so the item is inserted, rendered and documented as textDocument/completion gave it. A RequestCancelled or ContentModified error is ignored, as for other requests.
LSPRequestConstants.COMPLETION_ITEM_RESOLVE.
A resolve which succeeds works as before. An error which isn't a ResponseErrorException, a cancellation or a MessageIssueException still propagates, as it does for the other resolve requests.
Tests
CompletionItemResolveFailureTest has 3 tests, each with a server whose completionItem/resolve fails with an InternalError response:
selecting an item inserts it unresolved, after one resolve request;
the error is reported in a notification, with completionItem/resolve as its subtitle and the server's message as its content;
the expensive renderer of the selected item renders it unresolved, its detail isn't resolved again, and it has no documentation.
Without the change in LSPCompletionProposal, all 3 fail: the first two with the ResponseErrorException out of handleInsert, while the editor still has only the typed f, and the last with it out of the renderer. The other completion tests (com.redhat.devtools.lsp4ij.features.completion.*, 105 tests with the new ones) pass.
Locally, the full suite passes (1,006 tests, 3 skipped) except the 7 known macOS failures ("File accessed outside allowed roots"), which fail on main too. Not checked in a running IDE.
When a language server answers 'completionItem/resolve' with an error,
LSPCompletionProposal.getResolvedCompletionItem() lets it escape:
awaitWithCheckCanceled rethrows the failed request, and only
cancellations are caught. Selecting the item then inserts nothing and
IntelliJ reports an IDE error; the expensive renderer and the
documentation of the item fail the same way. Since 15aa49a (0.20.2)
the ExecutionException is no longer caught, and before that it was
logged as an error.
The request now goes through a CancellationSupport with its language
server, like the other resolve requests. A ResponseErrorException is
reported as the server's error reporting setting says, the request
completes with null, and the callers use the item unresolved.
CompletionItemResolveFailureTest: a failed resolve still inserts the
item, is reported in a notification, and the expensive renderer renders
the item unresolved. All 3 fail without the change in
LSPCompletionProposal; com.redhat.devtools.lsp4ij.features.completion.*
passes (105 tests).
Fixesredhat-developer#784
This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.
Completion suggestions can still be inserted when resolving additional item details fails.
Failed resolution is reported through an error notification, and the suggestion remains available without resolved details or documentation.
Completion-item resolution now supports cancellation, helping prevent unnecessary work when a request is no longer needed.
The completion proposal now submits item-resolution requests through cancellation support. New tests cover insertion, error notification, and unresolved rendering when a resolve request fails.
The change adds reporting and unresolved-item fallback for completion resolution errors. The remaining reporting concern predates this change and does not establish a merge blocker.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title says the change makes a completion item stay unresolved when its resolve fails. The raw summary and description confirm this: LSPCompletionProposal now routes completionItem/resolve through …
Description check
The description explains the cause (awaitWithCheckCanceled rethrowing a failed request after commit 15aa49a removed the catch), the fix (CancellationSupport for completionItem/resolve, null result on…
Linked Issues check
Issue #784 requires handling errors from completionItem/resolve with the TypeScript language server. The PR routes this request through CancellationSupport, reports ResponseErrorException accord…
Out of Scope Changes check
The changed request constant supports the new completionItem/resolve request path. The LSPCompletionProposal change implements issue #784. The three new tests verify the failure behavior. No unrel…
Full details: Title check
Explanation
The title says the change makes a completion item stay unresolved when its resolve fails. The raw summary and description confirm this: LSPCompletionProposal now routes completionItem/resolve through CancellationSupport, reports ResponseErrorException per the error-reporting setting, and completes with null so the item is inserted unresolved. The title is specific and matches the main change. The "fix:" prefix is conventional and does not hurt clarity.
Full details: Description check
Explanation
The description explains the cause (awaitWithCheckCanceled rethrowing a failed request after commit 15aa49a removed the catch), the fix (CancellationSupport for completionItem/resolve, null result on ResponseErrorException), the new constant, the three added tests, and the test results. It relates directly to the changeset and references issue #784.
Full details: Linked Issues check
Explanation
Issue #784 requires handling errors from completionItem/resolve with the TypeScript language server. The PR routes this request through CancellationSupport, reports ResponseErrorException according to the server setting, and completes the resolve with null. The existing completion item is then used unresolved. CompletionItemResolveFailureTest verifies insertion after one failed resolve, error notification content, and unresolved rendering without repeated detail resolution.
Full details: Out of Scope Changes check
Explanation
The changed request constant supports the new completionItem/resolve request path. The LSPCompletionProposal change implements issue #784. The three new tests verify the failure behavior. No unrelated change is identified in the supplied change summary.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.
The new CancellationSupport route classifies a ResponseErrorException only when it is the immediate exception. A resolve future completed exceptionally with a CompletionException wrapping that error may therefore bypass the configured language-server error report.
The item can fall back to unresolved insertion without the notification or log entry configured for its server error.
This can occur when: The text-document service supplies a resolve future whose failure is a CompletionException caused by a ResponseErrorException.
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: 78eac73f-4b45-4bdc-945d-6735866baeac
Commits
Reviewing files that changed from the base of the PR and between cec834e and c24cb36.
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
On CodeRabbit's unverified finding (a ResponseErrorException wrapped in a CompletionException skipping the error report): not changed. getTextDocumentService().resolveCompletionItem(item) returns LSP4J's request future, which LSP4J's RemoteEndpoint completes exceptionally with the ResponseErrorException itself; handle() on that future receives it unwrapped. A CompletionException would only wrap it in a dependent stage, and CancellationSupport is applied to the request future directly, as for every other LSP request. testAFailedResolveIsReportedLikeOtherLanguageServerErrors checks it: the server's error reaches the notification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a language server answers
completionItem/resolvewith an error, such as typescript-language-server's "Cannot read properties of undefined (reading 'file')" in #784, selecting the completion item inserts nothing: the typed prefix stays as it is, and IntelliJ reports theResponseErrorExceptionas an IDE error. The expensive renderer of the selected item, which is where #784's stack trace comes from, and the item's documentation fail with the same exception.LSPCompletionProposal.getResolvedCompletionItem()waits for the request withawaitWithCheckCanceled, which rethrows a failed request wrapped in aRuntimeException, and it catches only cancellations. Before 0.20.2 the wait caught theExecutionExceptionand logged it as an error, which is the IDE error in #784, and the item was then inserted unresolved.15aa49ae("perf: Use ProgressIndicatorUtils.awaitWithCheckCanceled", in 0.20.2) removed that catch, so the error now escapeshandleInsertbefore anything is inserted. The request was also sent without aCancellationSupport, so the server's Error reporting setting didn't apply to it, as it does to other LSP requests.Fixes #784.
Changes
LSPCompletionProposal.getResolvedCompletionItemFuture(): thecompletionItem/resolverequest now goes through aCancellationSupportwith its language server, likecodeLens/resolve,inlayHint/resolveanddocumentLink/resolve. AResponseErrorExceptionis reported as the server's Error reporting setting says (a notification by default, the log, or nothing), and the request completes with null. Every caller already takes null as "not resolved", so the item is inserted, rendered and documented astextDocument/completiongave it. ARequestCancelledorContentModifiederror is ignored, as for other requests.LSPRequestConstants.COMPLETION_ITEM_RESOLVE.A resolve which succeeds works as before. An error which isn't a
ResponseErrorException, a cancellation or aMessageIssueExceptionstill propagates, as it does for the other resolve requests.Tests
CompletionItemResolveFailureTesthas 3 tests, each with a server whosecompletionItem/resolvefails with anInternalErrorresponse:completionItem/resolveas its subtitle and the server's message as its content;detailisn't resolved again, and it has no documentation.Without the change in
LSPCompletionProposal, all 3 fail: the first two with theResponseErrorExceptionout ofhandleInsert, while the editor still has only the typedf, and the last with it out of the renderer. The other completion tests (com.redhat.devtools.lsp4ij.features.completion.*, 105 tests with the new ones) pass.Locally, the full suite passes (1,006 tests, 3 skipped) except the 7 known macOS failures ("File accessed outside allowed roots"), which fail on
maintoo. Not checked in a running IDE.