Skip to content

Commit aa74883

Browse files
authored
fix(q): handle ServiceQuotaExceededException that is returned from backend when iteration limits reached for plan and code generation of feature dev (#4242)
1 parent 748e35a commit aa74883

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import software.amazon.awssdk.services.codewhispererruntime.model.GetTaskAssistC
1111
import software.amazon.awssdk.services.codewhispererruntime.model.StartTaskAssistCodeGenerationResponse
1212
import software.amazon.awssdk.services.codewhispererruntime.model.ValidationException
1313
import software.amazon.awssdk.services.codewhispererstreaming.model.CodeWhispererStreamingException
14+
import software.amazon.awssdk.services.codewhispererstreaming.model.ServiceQuotaExceededException
1415
import software.amazon.awssdk.services.codewhispererstreaming.model.ThrottlingException
1516
import software.aws.toolkits.core.utils.debug
1617
import software.aws.toolkits.core.utils.getLogger
@@ -114,7 +115,9 @@ suspend fun generatePlan(
114115
errMssg = e.awsErrorDetails().errorMessage()
115116
logger.warn(e) { "Generate plan failed for request: ${e.requestId()}" }
116117

117-
if (e is ThrottlingException && e.message?.contains("limit for number of iterations on an implementation plan") == true) {
118+
if (e is ServiceQuotaExceededException ||
119+
(e is ThrottlingException && e.message?.contains("limit for number of iterations on an implementation plan") == true)
120+
) {
118121
throw PlanIterationLimitError(message("amazonqFeatureDev.approach_gen.iteration_limit.error_text"), e.cause)
119122
}
120123
}
@@ -142,9 +145,11 @@ fun startTaskAssistCodeGeneration(proxyClient: FeatureDevClient, conversationId:
142145
errMssg = e.awsErrorDetails().errorMessage()
143146
logger.warn(e) { "StartTaskAssistCodeGeneration failed for request: ${e.requestId()}" }
144147

145-
if (e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException && e.message?.contains(
146-
"limit for number of iterations on a code generation"
147-
) == true
148+
if (e is software.amazon.awssdk.services.codewhispererruntime.model.ServiceQuotaExceededException || (
149+
e is software.amazon.awssdk.services.codewhispererruntime.model.ThrottlingException && e.message?.contains(
150+
"limit for number of iterations on a code generation"
151+
) == true
152+
)
148153
) {
149154
throw CodeIterationLimitError(message("amazonqFeatureDev.code_generation.iteration_limit.error_text"), e.cause)
150155
}

plugins/core/sdk-codegen/codegen-resources/codewhispererruntime/service-2.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"output":{"shape":"CreateUploadUrlResponse"},
4040
"errors":[
4141
{"shape":"ThrottlingException"},
42+
{"shape":"ServiceQuotaExceededException"},
4243
{"shape":"ConflictException"},
4344
{"shape":"ResourceNotFoundException"},
4445
{"shape":"InternalServerException"},
@@ -63,6 +64,9 @@
6364
{
6465
"shape": "ThrottlingException"
6566
},
67+
{
68+
"shape": "ServiceQuotaExceededException"
69+
},
6670
{
6771
"shape": "InternalServerException"
6872
},
@@ -258,6 +262,7 @@
258262
"output":{"shape":"StartTaskAssistCodeGenerationResponse"},
259263
"errors":[
260264
{"shape":"ThrottlingException"},
265+
{"shape":"ServiceQuotaExceededException"},
261266
{"shape":"ConflictException"},
262267
{"shape":"ResourceNotFoundException"},
263268
{"shape":"InternalServerException"},
@@ -1560,6 +1565,15 @@
15601565
"exception":true,
15611566
"retryable":{"throttling":true}
15621567
},
1568+
"ServiceQuotaExceededException":{
1569+
"type":"structure",
1570+
"required":["message"],
1571+
"members":{
1572+
"message":{"shape":"String"}
1573+
},
1574+
"exception":true,
1575+
"retryable":{"throttling":true}
1576+
},
15631577
"TimeBetweenChunks": {
15641578
"type": "list",
15651579
"member": { "shape": "Double" },

plugins/core/sdk-codegen/codegen-resources/codewhispererstreaming/service-2.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"output":{"shape":"GenerateTaskAssistPlanResponse"},
5656
"errors":[
5757
{"shape":"ThrottlingException"},
58+
{"shape":"ServiceQuotaExceededException"},
5859
{"shape":"ConflictException"},
5960
{"shape":"ResourceNotFoundException"},
6061
{"shape":"InternalServerException"},
@@ -632,6 +633,15 @@
632633
"exception":true,
633634
"retryable":{"throttling":true}
634635
},
636+
"ServiceQuotaExceededException":{
637+
"type":"structure",
638+
"required":["message"],
639+
"members":{
640+
"message":{"shape":"String"}
641+
},
642+
"exception":true,
643+
"retryable":{"throttling":true}
644+
},
635645
"UploadId":{
636646
"type":"string",
637647
"max":128,

0 commit comments

Comments
 (0)