Skip to content

Commit 040b10b

Browse files
authored
fix(amazonq): throw if no region profiles are available (#7360)
Duplicate PR of #7357 into Flare branch ## 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 c17efa1 commit 040b10b

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
@@ -177,9 +177,17 @@ export class RegionProfileManager {
177177
}
178178
}
179179

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

185193
this._profiles = availableProfiles

0 commit comments

Comments
 (0)