Skip to content

Commit 7983fc1

Browse files
authored
fix(amazonq): throw if no region profiles are available (#7357)
## Problem When ListRegionProfile call throttles for a subset of regions, we currently do not throw, but instead return the available profiles in the regions where the call succeeded. However, if that list is empty (no profiles in that region), we return an empty list. This breaks the UI, and causes a state that is not recoverable ## Solution Throw an error in the scenario where availableProfiles is empty. This triggers a retry state in the UI, making the state recoverable. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 67295aa commit 7983fc1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,17 @@ export class RegionProfileManager {
182182
}
183183
}
184184

185-
// Only throw error if all regions fail
186-
if (failedRegions.length === endpoints.size) {
187-
throw new Error(`Failed to list profiles for all regions: ${failedRegions.join(', ')}`)
185+
// Throw error if any regional API calls failed and no profiles are available
186+
if (failedRegions.length > 0 && availableProfiles.length === 0) {
187+
throw new ToolkitError(`Failed to list Q Developer profiles for regions: ${failedRegions.join(', ')}`, {
188+
code: 'ListQDeveloperProfilesFailed',
189+
})
190+
}
191+
192+
// Throw an error if all listAvailableProfile calls succeeded, but user has no Q developer profiles
193+
// This is not an expected state
194+
if (failedRegions.length === 0 && availableProfiles.length === 0) {
195+
throw new ToolkitError('This user has no Q Developer profiles', { code: 'QDeveloperProfileNotFound' })
188196
}
189197

190198
this._profiles = availableProfiles

0 commit comments

Comments
 (0)