Skip to content

Commit be6ee35

Browse files
committed
fix(amazonq): add handling for new limit mechanism
1 parent 2a8fd52 commit be6ee35

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Amazon Q Feature Dev: display limit reached error message"
4+
}

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/util/FeatureDevService.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ class FeatureDevService(val proxyClient: FeatureDevClient, val project: Project)
135135
logger.warn(e) { "StartTaskAssistCodeGeneration failed for request: ${e.requestId()}" }
136136

137137
if (e is software.amazon.awssdk.services.codewhispererruntime.model.ServiceQuotaExceededException || (
138-
e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException && e.message?.contains(
139-
"limit for number of iterations on a code generation"
140-
) == true
138+
e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException && (
139+
e.message?.contains(
140+
"limit for number of iterations on a code generation"
141+
) == true || e.message?.contains("StartTaskAssistCodeGeneration reached for this month.") == true
142+
)
141143
)
142144
) {
143145
throw CodeIterationLimitException(operation = FeatureDevOperation.StartTaskAssistCodeGeneration.toString(), desc = null, e.cause)

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/util/FeatureDevServiceTest.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,37 @@ class FeatureDevServiceTest : FeatureDevTestBase() {
195195
)
196196
}
197197

198+
@Test
199+
fun `test startTaskAssistConversation throws ServiceQuotaExceededException, different case`() {
200+
val exampleCWException =
201+
ThrottlingException
202+
.builder()
203+
.awsErrorDetails(
204+
AwsErrorDetails.builder().errorMessage("StartTaskAssistCodeGeneration reached for this month.").build(),
205+
).build()
206+
whenever(
207+
featureDevClient.startTaskAssistCodeGeneration(
208+
testConversationId,
209+
testUploadId,
210+
userMessage,
211+
codeGenerationId = codeGenerationId,
212+
currentCodeGenerationId = "EMPTY_CURRENT_CODE_GENERATION_ID",
213+
),
214+
).thenThrow(exampleCWException)
215+
216+
assertThatThrownBy {
217+
featureDevService.startTaskAssistCodeGeneration(
218+
testConversationId,
219+
testUploadId,
220+
userMessage,
221+
codeGenerationId = codeGenerationId,
222+
currentCodeGenerationId = "EMPTY_CURRENT_CODE_GENERATION_ID",
223+
)
224+
}.isExactlyInstanceOf(CodeIterationLimitException::class.java).withFailMessage(
225+
message("amazonqFeatureDev.code_generation.iteration_limit.error_text"),
226+
)
227+
}
228+
198229
@Test
199230
fun `test startTaskAssistConversation throws ServiceQuotaExceededException`() {
200231
val exampleCWException =
@@ -226,6 +257,7 @@ class FeatureDevServiceTest : FeatureDevTestBase() {
226257
)
227258
}
228259

260+
229261
@Test
230262
fun `test startTaskAssistConversation throws another CodeWhispererRuntimeException`() {
231263
val exampleCWException =

0 commit comments

Comments
 (0)