Skip to content

Commit 80273ee

Browse files
Merge master into feature/amazonqLSP-auth
2 parents bab2bc1 + d6d839a commit 80273ee

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Users might be bound to a customization which they dont have access with the selected profile and it causes service throwing 403 when using inline suggestion and chat features"
4+
}

packages/core/src/codewhisperer/activation.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ import { AuthUtil } from './util/authUtil'
7272
import { ImportAdderProvider } from './service/importAdderProvider'
7373
import { TelemetryHelper } from './util/telemetryHelper'
7474
import { openUrl } from '../shared/utilities/vsCodeUtils'
75-
import { notifyNewCustomizations } from './util/customizationUtil'
75+
import {
76+
getAvailableCustomizationsList,
77+
getSelectedCustomization,
78+
notifyNewCustomizations,
79+
switchToBaseCustomizationAndNotify,
80+
} from './util/customizationUtil'
7681
import { CodeWhispererCommandBackend, CodeWhispererCommandDeclarations } from './commands/gettingStartedPageCommands'
7782
import { SecurityIssueHoverProvider } from './service/securityIssueHoverProvider'
7883
import { SecurityIssueCodeActionProvider } from './service/securityIssueCodeActionProvider'
@@ -337,7 +342,27 @@ export async function activate(context: ExtContext): Promise<void> {
337342
[...CodeWhispererConstants.securityScanLanguageIds],
338343
SecurityIssueCodeActionProvider.instance
339344
),
340-
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange)
345+
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange),
346+
auth.regionProfileManager.onDidChangeRegionProfile(() => {
347+
// Validate user still has access to the selected customization.
348+
const selectedCustomization = getSelectedCustomization()
349+
// No need to validate base customization which has empty arn.
350+
if (selectedCustomization.arn.length > 0) {
351+
getAvailableCustomizationsList()
352+
.then(async (customizations) => {
353+
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
354+
if (!r) {
355+
await switchToBaseCustomizationAndNotify()
356+
}
357+
})
358+
.catch((e) => {
359+
getLogger().error(
360+
`encounter error while validating selected customization on profile change: %s`,
361+
(e as Error).message
362+
)
363+
})
364+
}
365+
})
341366
)
342367

343368
// run the auth startup code with context for telemetry

packages/core/src/codewhisperer/region/regionProfileManager.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const defaultServiceConfig: CodeWhispererConfig = {
3030
}
3131

3232
// Hack until we have a single discovery endpoint. We will call each endpoint one by one to fetch profile before then.
33-
// TODO: update correct endpoint and region
3433
const endpoints = createConstantMap({
3534
'us-east-1': 'https://q.us-east-1.amazonaws.com/',
3635
'eu-central-1': 'https://q.eu-central-1.amazonaws.com/',

0 commit comments

Comments
 (0)