Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"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"
}
28 changes: 26 additions & 2 deletions packages/core/src/codewhisperer/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ import { AuthUtil } from './util/authUtil'
import { ImportAdderProvider } from './service/importAdderProvider'
import { TelemetryHelper } from './util/telemetryHelper'
import { openUrl } from '../shared/utilities/vsCodeUtils'
import { notifyNewCustomizations } from './util/customizationUtil'
import {
getAvailableCustomizationsList,
getSelectedCustomization,
notifyNewCustomizations,
switchToBaseCustomizationAndNotify,
} from './util/customizationUtil'
import { CodeWhispererCommandBackend, CodeWhispererCommandDeclarations } from './commands/gettingStartedPageCommands'
import { SecurityIssueHoverProvider } from './service/securityIssueHoverProvider'
import { SecurityIssueCodeActionProvider } from './service/securityIssueCodeActionProvider'
Expand Down Expand Up @@ -337,7 +342,26 @@ export async function activate(context: ExtContext): Promise<void> {
[...CodeWhispererConstants.securityScanLanguageIds],
SecurityIssueCodeActionProvider.instance
),
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange)
vscode.commands.registerCommand('aws.amazonq.openEditorAtRange', openEditorAtRange),
auth.regionProfileManager.onDidChangeRegionProfile(() => {
// validate user's still has access to the selected customization
const selectedCustomization = getSelectedCustomization()
// no need to validate base customization which has empty arn
if (selectedCustomization.arn.length > 0) {
getAvailableCustomizationsList()
.then((customizations) => {
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
if (!r) {
void switchToBaseCustomizationAndNotify().then()
}
})
.catch((e) => {
getLogger().error(
`encounter error while validating selected customization on profile change: ${(e as Error).message}`
)
})
}
})
)

// run the auth startup code with context for telemetry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const defaultServiceConfig: CodeWhispererConfig = {
}

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