44 */
55
66import * as vscode from 'vscode'
7- import { ToolkitError } from '../../errors'
7+ import { getErrorMsg , ToolkitError } from '../../errors'
88import { Logger } from '../../logger/logger'
99import { ChildProcess } from '../../utilities/processUtils'
1010import { 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