Skip to content

Commit 578d406

Browse files
skyrpexvalerena
authored andcommitted
split customUserAgentBase into user agent name and version
This prevents future mistakes by exposing a readonly array `customUserAgentBase` in non-readonly arrays in methods such as `getLambdaDebugUserAgentPairs()`
1 parent 9cf0cb6 commit 578d406

File tree

1 file changed

+7
-3
lines changed
  • packages/core/src/lambda/remoteDebugging

1 file changed

+7
-3
lines changed

packages/core/src/lambda/remoteDebugging/utils.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { getUserAgentPairs, userAgentPairsToString } from '../../shared/telemetr
99
import globals from '../../shared/extensionGlobals'
1010
import type { UserAgent } from '@aws-sdk/types'
1111

12-
const customUserAgentBase: [string, string] = ['LAMBDA-DEBUG', '1.0.0']
12+
const customUserAgentName = 'LAMBDA-DEBUG'
13+
const customUserAgentVersion = '1.0.0'
1314

1415
export function getLambdaClientWithAgent(region: string, customUserAgent?: UserAgent): DefaultLambdaClient {
1516
if (!customUserAgent) {
@@ -22,7 +23,10 @@ export function getLambdaClientWithAgent(region: string, customUserAgent?: UserA
2223
* Returns properly formatted UserAgent pairs for AWS SDK v3
2324
*/
2425
export function getLambdaDebugUserAgentPairs(): UserAgent {
25-
return [customUserAgentBase, ...getUserAgentPairs({ includePlatform: true, includeClientId: true })]
26+
return [
27+
[customUserAgentName, customUserAgentVersion],
28+
...getUserAgentPairs({ includePlatform: true, includeClientId: true }),
29+
]
2630
}
2731

2832
/**
@@ -44,7 +48,7 @@ export function getIoTSTClientWithAgent(region: string): IoTSecureTunnelingClien
4448
return globals.sdkClientBuilderV3.createAwsService({
4549
serviceClient: IoTSecureTunnelingClient,
4650
clientOptions: {
47-
customUserAgent: [customUserAgentBase],
51+
customUserAgent: [[customUserAgentName, customUserAgentVersion]],
4852
region,
4953
},
5054
userAgent: false,

0 commit comments

Comments
 (0)