File tree Expand file tree Collapse file tree
test/sagemakerunifiedstudio Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { ExtContext } from '../shared/extensions'
99import { deeplinkConnect } from '../awsService/sagemaker/commands'
1010import { telemetry } from '../shared/telemetry/telemetry'
1111import { SmusAuthMode } from '../shared/telemetry/telemetry.gen'
12+ import { getLogger } from '../shared/logger/logger'
1213
1314const amzHeaders = [
1415 'X-Amz-Security-Token' ,
@@ -96,6 +97,19 @@ export function register(ctx: ExtContext) {
9697 * @throws Error if required parameters are missing
9798 */
9899export function parseConnectParams ( query : SearchParams ) {
100+ // Extract session from ws_url as fallback. When the deep link URL contains sigv4 params
101+ // embedded inside ws_url with single percent-encoding, VS Code's URI parser can decode
102+ // the %26 separators, causing those params to break out as top-level query params and
103+ // displacing 'session'. The session ID is always present in the ws_url data-channel path.
104+ const wsUrl = query . get ( 'ws_url' )
105+ if ( ! query . has ( 'session' ) && wsUrl ) {
106+ const match = wsUrl . match ( / d a t a - c h a n n e l \/ ( [ ^ ? & ] + ) / )
107+ if ( match ) {
108+ getLogger ( ) . info ( `Recovered missing session from ws_url: ${ match [ 1 ] } ` )
109+ query . set ( 'session' , match [ 1 ] )
110+ }
111+ }
112+
99113 const requiredParams = query . getFromKeysOrThrow (
100114 'connection_identifier' ,
101115 'domain' ,
Original file line number Diff line number Diff line change @@ -111,6 +111,18 @@ describe('SMUS URI Handler', function () {
111111 assert . strictEqual ( resultWithoutOptional . smus_project_id , undefined )
112112 assert . strictEqual ( resultWithoutOptional . smus_domain_region , undefined )
113113 } )
114+
115+ it ( 'recovers session from ws_url when session param is missing' , function ( ) {
116+ const { session : _removed , ...paramsWithoutSession } = validParams
117+ const paramsWithDataChannel = {
118+ ...paramsWithoutSession ,
119+ ws_url : 'wss://ssmmessages.us-west-2.amazonaws.com/v1/data-channel/SageMaker-remote-abc123?role=publish_subscribe' ,
120+ }
121+ const query = new SearchParams ( paramsWithDataChannel )
122+ const result = parseConnectParams ( query )
123+
124+ assert . strictEqual ( result . session , 'SageMaker-remote-abc123' )
125+ } )
114126 } )
115127
116128 it ( 'properly encodes cell-number with spaces and special characters' , async function ( ) {
You can’t perform that action at this time.
0 commit comments