commit | 17390e59614cae397906364f26359055a91d2b1a | [log] [tgz] |
---|---|---|
author | Hongxiang Jiang <hxjiang@golang.org> | Tue Mar 04 11:04:18 2025 -0500 |
committer | Hongxiang Jiang <hxjiang@golang.org> | Tue Mar 04 12:39:35 2025 -0800 |
tree | 7c54a671a488436c8a3f9188ec1dbce231da7222 | |
parent | 07561fd5c7ab67a8ae80870f9d3208a21b8820c3 [diff] |
[release-v0.46]extension/src/language: check token field existence before assertion The error happens when the workspace/executeCommand returns results without any token. vscode-go tried to assert the type of "Token" field without checking for it's existence. Command with token returned (gopls.vulncheck): https://github.com/user-attachments/assets/931524ba-a40b-4a8c-b7af-a350a4c9a135 Command without token returned (gopls.upgrade_dependency): https://github.com/user-attachments/assets/cb23c5bc-7d0b-4e60-aa4e-66ba1fed31d8 For golang/vscode-go#3698 Change-Id: I07183b7e0f30912a6b3f6c0ab53a40624ccd7880 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/654555 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> kokoro-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Madeline Kalil <mkalil@google.com> (cherry picked from commit 7a2c83556ae55ea1067e44c4569faae8b5d71712) Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/654775
diff --git a/extension/src/language/goLanguageServer.ts b/extension/src/language/goLanguageServer.ts index b446e8c..5923aa8 100644 --- a/extension/src/language/goLanguageServer.ts +++ b/extension/src/language/goLanguageServer.ts
@@ -565,7 +565,7 @@ } const res = await next(command, args); - const progressToken = <ProgressToken>res.Token; + const progressToken = res?.Token as ProgressToken; // The progressToken from executeCommand indicates that // gopls may trigger a related workDoneProgress // notification, either before or after the command