Skip to content

Commit 90f5459

Browse files
authored
fix(sagemaker): fix sagemaker.parseCookies cmd not found (#7670)
## Problem After Remote - SSH to a sagemaker space via VS Code, the amazon Q plugin cannot be loaded for the following error. ``` 2025-07-10 17:23:52.976 [info] ExtensionService#_doActivateExtension amazonwebservices.aws-toolkit-vscode, startup: false, activationEvent: 'onStartupFinished' 2025-07-10 17:23:57.478 [error] Activating extension amazonwebservices.amazon-q-vscode failed due to an error: 2025-07-10 17:23:57.478 [error] Error: command 'sagemaker.parseCookies' not found at mYe.n (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1855:1328) at mYe.executeCommand (vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1855:1260) ``` ## Solution After discussed with the Sagemaker team folks @sunp and @arkaprav, we decide that if cmd `sagemaker.parseCookies` not found, we just swallow the error and add a log for it. ### Test a local build is created for testing. <img width="1198" height="793" alt="image" src="https://github.com/user-attachments/assets/ea726d78-6cb9-4e91-bad7-f0da43cf4c83" /> --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c917133 commit 90f5459

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

packages/core/src/auth/activation.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@ import { LoginManager } from './deprecated/loginManager'
99
import { fromString } from './providers/credentials'
1010
import { initializeCredentialsProviderManager } from './utils'
1111
import { isAmazonQ, isSageMaker } from '../shared/extensionUtilities'
12+
import { getLogger } from '../shared/logger/logger'
13+
import { getErrorMsg } from '../shared/errors'
1214

1315
interface SagemakerCookie {
1416
authMode?: 'Sso' | 'Iam'
1517
}
1618

1719
export async function initialize(loginManager: LoginManager): Promise<void> {
1820
if (isAmazonQ() && isSageMaker()) {
19-
// The command `sagemaker.parseCookies` is registered in VS Code Sagemaker environment.
20-
const result = (await vscode.commands.executeCommand('sagemaker.parseCookies')) as SagemakerCookie
21-
if (result.authMode !== 'Sso') {
22-
initializeCredentialsProviderManager()
21+
try {
22+
// The command `sagemaker.parseCookies` is registered in VS Code Sagemaker environment.
23+
const result = (await vscode.commands.executeCommand('sagemaker.parseCookies')) as SagemakerCookie
24+
if (result.authMode !== 'Sso') {
25+
initializeCredentialsProviderManager()
26+
}
27+
} catch (e) {
28+
const errMsg = getErrorMsg(e as Error)
29+
if (errMsg?.includes("command 'sagemaker.parseCookies' not found")) {
30+
getLogger().warn(`Failed to execute command "sagemaker.parseCookies": ${e}`)
31+
} else {
32+
throw e
33+
}
2334
}
2435
}
2536
Auth.instance.onDidChangeActiveConnection(async (conn) => {

0 commit comments

Comments
 (0)