Skip to content

Commit ed7cb84

Browse files
authored
fix(q): Handle monthly conversation limit error for Q Feature development (#4818)
* fix(q): Handle monthly conversation limit error for Amazon Q feature development
1 parent 7f22a99 commit ed7cb84

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
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": "Amazon Q Feature Development: Update error message for monthly conversation limit reach"
4+
}

packages/core/src/amazonqFeatureDev/client/featureDev.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ApiError,
1818
CodeIterationLimitError,
1919
ContentLengthError,
20+
MonthlyConversationLimitError,
2021
PlanIterationLimitError,
2122
UnknownApiError,
2223
} from '../errors'
@@ -78,6 +79,9 @@ export class FeatureDevClient {
7879
getLogger().error(
7980
`${featureName}: failed to start conversation: ${e.message} RequestId: ${e.requestId}`
8081
)
82+
if (e.code === 'ServiceQuotaExceededException') {
83+
throw new MonthlyConversationLimitError(e.message)
84+
}
8185
throw new ApiError(e.message, 'CreateConversation', e.code, e.statusCode ?? 400)
8286
}
8387

packages/core/src/amazonqFeatureDev/controllers/chat/controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { featureDevScheme } from '../../constants'
1414
import {
1515
CodeIterationLimitError,
1616
ContentLengthError,
17+
MonthlyConversationLimitError,
1718
PlanIterationLimitError,
1819
SelectedFolderNotInWorkspaceFolderError,
1920
createUserFacingErrorMessage,
@@ -242,6 +243,8 @@ export class FeatureDevController {
242243
},
243244
],
244245
})
246+
} else if (err instanceof MonthlyConversationLimitError) {
247+
this.messenger.sendMonthlyLimitError(message.tabID)
245248
} else if (err instanceof PlanIterationLimitError) {
246249
this.messenger.sendErrorMessage(err.message, message.tabID, this.retriesRemaining(session))
247250
this.messenger.sendAnswer({

packages/core/src/amazonqFeatureDev/controllers/chat/messenger/messenger.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ export class Messenger {
4646
)
4747
}
4848

49+
public sendMonthlyLimitError(tabID: string) {
50+
this.sendAnswer({
51+
type: 'answer',
52+
tabID: tabID,
53+
message: `Sorry, you have reached the monthly limit for feature development. You can try again next month.`,
54+
})
55+
this.sendUpdatePlaceholder(tabID, 'Chat input is disabled')
56+
}
57+
4958
public sendErrorMessage(errorMessage: string, tabID: string, retries: number, phase?: SessionStatePhase) {
5059
if (retries === 0) {
5160
this.dispatcher.sendErrorMessage(

packages/core/src/amazonqFeatureDev/errors.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ export class CodeIterationLimitError extends ToolkitError {
9595
}
9696
}
9797

98+
export class MonthlyConversationLimitError extends ToolkitError {
99+
constructor(message: string) {
100+
super(message, { code: 'MonthlyConversationLimitError' })
101+
}
102+
}
103+
98104
export class UnknownApiError extends ToolkitError {
99105
constructor(message: string, api: string) {
100106
super(message, { code: `${api}-Unknown` })

0 commit comments

Comments
 (0)