From 7a2c83556ae55ea1067e44c4569faae8b5d71712 Mon Sep 17 00:00:00 2001 From: Hongxiang Jiang Date: Tue, 4 Mar 2025 11:04:18 -0500 Subject: [PATCH] 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 LUCI-TryBot-Result: Go LUCI kokoro-CI: kokoro Reviewed-by: Madeline Kalil --- extension/src/language/goLanguageServer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension/src/language/goLanguageServer.ts b/extension/src/language/goLanguageServer.ts index b446e8c0a7..5923aa88f6 100644 --- a/extension/src/language/goLanguageServer.ts +++ b/extension/src/language/goLanguageServer.ts @@ -565,7 +565,7 @@ export async function buildLanguageClient( } const res = await next(command, args); - const 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