From 9f79663e8fbb0dacba7e5789858b113671dce951 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 20 Aug 2026 11:11:31 -0400 Subject: [PATCH 1/2] Fix AxiosError on activation --- CHANGELOG.md | 4 + client/src/extension.ts | 136 +++++++++++++++++++--------------- client/src/makeRESTRequest.ts | 9 +-- 3 files changed, 82 insertions(+), 67 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 970cfca..24e1608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [2.8.5] - 2026-08-XX +- PR [#410](https://github.com/intersystems/language-server/pull/410): Fix hover intellisense for macros +- Fix issue [#411](https://github.com/intersystems/language-server/issues/411): AxiosError 405 on activation + ## [2.8.4] - 2026-08-11 - Fix issue [#391](https://github.com/intersystems/language-server/issues/391): Parser support for SQL WITH clause - Fix issue [#397](https://github.com/intersystems/language-server/issues/397): Enable use of Automatic Symbol References feature in AI chat diff --git a/client/src/extension.ts b/client/src/extension.ts index 767513e..eaf7dc4 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -165,77 +165,93 @@ export async function activate(context: ExtensionContext) { // Resolve the ServerSpec for a document or workspace folder URI, prompting // for a missing password via the Server Manager's authentication provider. async function resolveServerSpec(uri: Uri) { - const wsFolderUriString = workspace.getWorkspaceFolder(uri)?.uri.toString(); - const serverSpec = objectScriptApi.serverForUri(uri)!; - const auth = serverSpec.auth ?? new BasicAuthorization(serverSpec.username, serverSpec.password); - if ( - // Server was resolved - serverSpec.host !== "" && - // Connection isn't unauthenticated - auth.username != undefined && - auth.username != "" && - auth.username.toLowerCase() != "unknownuser" && - // A password is missing - typeof auth.password === "undefined" && - // A supported version of the Server Manager is installed - serverManagerExt != undefined && - gt(serverManagerExt.packageJSON.version, "3.0.0") - ) { - // The main extension didn't provide a password, so we must - // get it from the server manager's authentication provider. - const scopes = [serverSpec.serverName, auth.username]; - try { - const account = serverManagerApi?.getAccount - ? serverManagerApi.getAccount({ name: serverSpec.serverName, ...serverSpec }) - : undefined; - let session = await authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { - silent: true, - account, - }); - if (!session) { - session = await authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { - createIfNone: true, + try { + const wsFolderUriString = workspace.getWorkspaceFolder(uri)?.uri.toString(); + const serverSpec = objectScriptApi.serverForUri(uri)!; + const auth = serverSpec.auth ?? new BasicAuthorization(serverSpec.username, serverSpec.password); + if ( + // Server was resolved + serverSpec.host !== "" && + // Connection isn't unauthenticated + auth.username != undefined && + auth.username != "" && + auth.username.toLowerCase() != "unknownuser" && + // A password is missing + typeof auth.password === "undefined" && + // A supported version of the Server Manager is installed + serverManagerExt != undefined && + gt(serverManagerExt.packageJSON.version, "3.0.0") + ) { + // The main extension didn't provide a password, so we must + // get it from the server manager's authentication provider. + const scopes = [serverSpec.serverName, auth.username]; + try { + const account = serverManagerApi?.getAccount + ? serverManagerApi.getAccount({ name: serverSpec.serverName, ...serverSpec }) + : undefined; + let session = await authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { + silent: true, account, }); - } - if (session) { - auth.resolve({ - username: session.scopes[1], - accessToken: session.accessToken, - }); - } - } catch (error) { - // The user did not consent to sharing authentication information - if (error instanceof Error) { - client.warn(`${serverManager.AUTHENTICATION_PROVIDER}: ${error.message}`); + if (!session) { + session = await authentication.getSession(serverManager.AUTHENTICATION_PROVIDER, scopes, { + createIfNone: true, + account, + }); + } + if (session) { + auth.resolve({ + username: session.scopes[1], + accessToken: session.accessToken, + }); + } + } catch (error) { + // The user did not consent to sharing authentication information + if (error instanceof Error) { + client.warn(`${serverManager.AUTHENTICATION_PROVIDER}: ${error.message}`); + } } } + if ( + typeof auth.username == "string" && + auth.username.toLowerCase() == "unknownuser" && + typeof auth.password == "undefined" + ) { + // UnknownUser without a password means "unauthenticated" + auth.clear() as void; + } + const server: ServerSpec = { + ...serverSpec, + username: auth.username, + credentials: auth.credentials, + }; + if (wsFolderUriString && !wsFolderServerSpecs.has(wsFolderUriString)) { + wsFolderServerSpecs.set(wsFolderUriString, server); + } + return server; + } catch { + // Treat any thrown error as "no server connection" + return { + serverName: "", + active: false, + apiVersion: 1, + serverVersion: "", + scheme: "http", + host: "", + port: 0, + pathPrefix: "", + namespace: "", + username: "", + } as ServerSpec; } - if ( - typeof auth.username == "string" && - auth.username.toLowerCase() == "unknownuser" && - typeof auth.password == "undefined" - ) { - // UnknownUser without a password means "unauthenticated" - auth.clear() as void; - } - const server: ServerSpec = { - ...serverSpec, - username: auth.username, - credentials: auth.credentials, - }; - if (wsFolderUriString && !wsFolderServerSpecs.has(wsFolderUriString)) { - wsFolderServerSpecs.set(wsFolderUriString, server); - } - return server; } // Ensure that every server has at most one session. for (const f of workspace.workspaceFolders ?? []) { try { const serverSpec = await resolveServerSpec(f.uri); - if (serverSpec.active) { - await makeRESTRequest("HEAD", 1, "", serverSpec); + if (serverSpec?.active) { + await makeRESTRequest("HEAD", 0, "", serverSpec); } } catch { // Ignore any failure; the session will be created on demand instead diff --git a/client/src/makeRESTRequest.ts b/client/src/makeRESTRequest.ts index cf0044f..f53a0c7 100644 --- a/client/src/makeRESTRequest.ts +++ b/client/src/makeRESTRequest.ts @@ -26,13 +26,8 @@ export async function makeRESTRequest( checksum?: string, params?: AxiosRequestConfig["params"], ): Promise | undefined> { - if (server.host === "") { - // No server connection is configured - client.warn("Cannot make required REST request because no server connection is configured."); - return undefined; - } - if (!server.active) { - // Server connection is inactive + if (!server?.host || !server.active) { + // No server connection is configured or it's inactive return undefined; } if (api > server.apiVersion) { From 49386fbaabf7e34e4432ab55c970e1b08ce814a8 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 20 Aug 2026 16:24:10 -0400 Subject: [PATCH 2/2] Update extension.ts --- client/src/extension.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/extension.ts b/client/src/extension.ts index eaf7dc4..38e91b0 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -164,7 +164,7 @@ export async function activate(context: ExtensionContext) { // Resolve the ServerSpec for a document or workspace folder URI, prompting // for a missing password via the Server Manager's authentication provider. - async function resolveServerSpec(uri: Uri) { + async function resolveServerSpec(uri: Uri): Promise { try { const wsFolderUriString = workspace.getWorkspaceFolder(uri)?.uri.toString(); const serverSpec = objectScriptApi.serverForUri(uri)!; @@ -242,7 +242,7 @@ export async function activate(context: ExtensionContext) { pathPrefix: "", namespace: "", username: "", - } as ServerSpec; + }; } }