Skip to content

Commit 5566901

Browse files
committed
fix(amazonq): sagemaker vscode remote ssh missing IAM creds
1 parent e49f15f commit 5566901

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/core/src/shared/lsp/utils/platform.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import * as vscode from 'vscode'
7-
import { ToolkitError } from '../../errors'
7+
import { getErrorMsg, ToolkitError } from '../../errors'
88
import { Logger } from '../../logger/logger'
99
import { ChildProcess } from '../../utilities/processUtils'
1010
import { waitUntil } from '../../utilities/timeoutUtils'
@@ -111,6 +111,10 @@ export function createServerOptions({
111111
// Set USE_IAM_AUTH environment variable for SageMaker environments based on cookie detection
112112
// This tells the language server to use IAM authentication mode instead of SSO mode
113113
const env = { ...process.env }
114+
115+
// eslint-disable-next-line aws-toolkits/no-json-stringify-in-log
116+
getLogger().debug(`[yueny debug] vars in env: ${JSON.stringify(env)}`)
117+
114118
if (isSageMaker()) {
115119
try {
116120
// The command `sagemaker.parseCookies` is registered in VS Code SageMaker environment
@@ -125,7 +129,13 @@ export function createServerOptions({
125129
}
126130
} catch (err) {
127131
getLogger().warn(`[SageMaker Debug] Failed to parse SageMaker cookies, defaulting to IAM auth: ${err}`)
128-
env.USE_IAM_AUTH = 'true'
132+
const errMsg = getErrorMsg(err as Error)
133+
if (errMsg?.includes("command 'sagemaker.parseCookies' not found")) {
134+
getLogger().warn('[yueny debug] SageMaker cookies not found, set env.USE_IAM_AUTH as false')
135+
env.USE_IAM_AUTH = 'false'
136+
} else {
137+
env.USE_IAM_AUTH = 'true'
138+
}
129139
}
130140

131141
// Log important environment variables for debugging

0 commit comments

Comments
 (0)