Skip to content

Commit c2f1210

Browse files
authored
fix(amazonq): dev profile selection breaks if certain regions aren't … (aws#7203)
## Problem Customer reported when a certain region is blocked(i.e. by cooperate network), it causes the Q developer profile list to break, and the customer can no longer use Q. ## Solution Don't throw immediately when a region is unavailable. So that the user still have access to working regions. Only throw if all regions are failing. ## Testing Shared the VSIX with customer and confirmed that issue is resolved. --- - 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 4f1f8b4 commit c2f1210

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-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": "Q profile selection hangs when a region is blocked"
4+
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export class RegionProfileManager {
138138
return []
139139
}
140140
const availableProfiles: RegionProfile[] = []
141+
const failedRegions: string[] = []
142+
141143
for (const [region, endpoint] of endpoints.entries()) {
142144
const client = await this.createQClient(region, endpoint, conn as SsoConnection)
143145
const requester = async (request: CodeWhispererUserClient.ListAvailableProfilesRequest) =>
@@ -162,13 +164,17 @@ export class RegionProfileManager {
162164
})
163165

164166
availableProfiles.push(...mappedPfs)
167+
RegionProfileManager.logger.debug(`Found ${mappedPfs.length} profiles in region ${region}`)
165168
} catch (e) {
166169
const logMsg = isAwsError(e) ? `requestId=${e.requestId}; message=${e.message}` : (e as Error).message
167-
RegionProfileManager.logger.error(`failed to listRegionProfile: ${logMsg}`)
168-
throw e
170+
RegionProfileManager.logger.error(`Failed to list profiles for region ${region}: ${logMsg}`)
171+
failedRegions.push(region)
169172
}
173+
}
170174

171-
RegionProfileManager.logger.info(`available amazonq profiles: ${availableProfiles.length}`)
175+
// Only throw error if all regions fail
176+
if (failedRegions.length === endpoints.size) {
177+
throw new Error(`Failed to list profiles for all regions: ${failedRegions.join(', ')}`)
172178
}
173179

174180
this._profiles = availableProfiles

0 commit comments

Comments
 (0)