Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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"
}
29 changes: 27 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,27 @@ 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 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(async (customizations) => {
const r = customizations.find((it) => it.arn === selectedCustomization.arn)
if (!r) {
await switchToBaseCustomizationAndNotify()
Copy link
Contributor

@justinmk3 justinmk3 Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switchToBaseCustomizationAndNotify() is not slow (no network calls), so it's ok for it to be await'd, right?

If you want it to be async also, then would be:

switchToBaseCustomizationAndNotify().catch(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, thanks for explanation :)

}
})
.catch((e) => {
getLogger().error(
`encounter error while validating selected customization on profile change: %s`,
(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