Skip to content

Commit 7e4f6e3

Browse files
chengoramazonrli
andauthored
fix(dev): add error messages for upload URL expiry (#4949)
* fix(dev): add error messages for upload URL expiry * Update .changes/next-release/bugfix-caf370b9-c943-4ece-a4c0-81bcefa7a4f5.json Co-authored-by: Richard Li <[email protected]> --------- Co-authored-by: Richard Li <[email protected]>
1 parent 8f9c157 commit 7e4f6e3

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-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: Add error messages when the upload URL expires"
4+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ class CodeIterationLimitError(override val message: String, override val cause:
1616

1717
class MonthlyConversationLimitError(override val message: String, override val cause: Throwable?) : RuntimeException()
1818

19+
class UploadURLExpired(
20+
override val message: String = message(
21+
"amazonqFeatureDev.exception.upload_url_expiry"
22+
),
23+
override val cause: Throwable? = null,
24+
) : FeatureDevException(message, cause)
25+
1926
internal fun featureDevServiceError(message: String?): Nothing =
2027
throw FeatureDevException(message)
2128

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevController.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.FeatureDevExce
3636
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.InboundAppMessagesHandler
3737
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.ModifySourceFolderErrorReason
3838
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.MonthlyConversationLimitError
39+
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.UploadURLExpired
3940
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.ZipFileError
4041
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.createUserFacingErrorMessage
4142
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.denyListedErrors
@@ -444,6 +445,12 @@ class FeatureDevController(
444445
messenger.sendMonthlyLimitError(tabId = tabId)
445446
messenger.sendChatInputEnabledMessage(tabId, enabled = false)
446447
}
448+
is UploadURLExpired -> messenger.sendAnswer(
449+
tabId = tabId,
450+
message = err.message,
451+
messageType = FeatureDevMessageType.Answer,
452+
canBeVoted = true
453+
)
447454
is FeatureDevException -> {
448455
messenger.sendError(
449456
tabId = tabId,
@@ -471,7 +478,6 @@ class FeatureDevController(
471478
),
472479
)
473480
}
474-
475481
else -> {
476482
var msg = createUserFacingErrorMessage("$FEATURE_NAME request failed: ${err.message ?: err.cause?.message}")
477483
val isDenyListedError = denyListedErrors.any { msg?.contains(it) ?: false }

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import software.aws.toolkits.jetbrains.services.amazonq.CONTENT_SHA256
1414
import software.aws.toolkits.jetbrains.services.amazonq.SERVER_SIDE_ENCRYPTION
1515
import software.aws.toolkits.jetbrains.services.amazonq.SERVER_SIDE_ENCRYPTION_AWS_KMS_KEY_ID
1616
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.FEATURE_NAME
17+
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.UploadURLExpired
1718
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.clients.FeatureDevClient
1819
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.uploadCodeError
1920
import java.io.File
@@ -36,9 +37,13 @@ fun uploadArtifactToS3(url: String, fileToUpload: File, checksumSha256: String,
3637
connection.setFixedLengthStreamingMode(fileToUpload.length())
3738
IoUtils.copy(fileToUpload.inputStream(), connection.outputStream)
3839
}
39-
} catch (err: Exception) {
40+
} catch (err: HttpRequests.HttpStatusException) {
4041
logger.warn(err) { "$FEATURE_NAME: Failed to upload code to S3" }
41-
uploadCodeError()
42+
43+
when (err.statusCode) {
44+
403 -> throw UploadURLExpired()
45+
else -> uploadCodeError()
46+
}
4247
}
4348
}
4449

plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ amazonqFeatureDev.exception.request_failed=Request failed
7272
amazonqFeatureDev.exception.retry_request_failed=Retry request failed
7373
amazonqFeatureDev.exception.throttling=I'm sorry, I'm experiencing high demand at the moment and can't generate your code. This attempt won't count toward usage limits. Please try again.
7474
amazonqFeatureDev.exception.upload_code=I'm sorry, I couldn't upload your workspace artifacts to Amazon S3 to help you with this task. You might need to allow access to the S3 bucket. For more information, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/security_iam_manage-access-with-policies.html#data-perimeters) or contact your network or organization administrator.
75+
amazonqFeatureDev.exception.upload_url_expiry=I'm sorry, I wasn't able to generate code. A connection timed out or became unavailable. Please try again or check the following:\n\n- Exclude non-essential files in your workspace's `.gitignore`.\n\n- Check that your network connection is stable.
7576
amazonqFeatureDev.follow_instructions_for_authentication=Follow instructions to re-authenticate ...
7677
amazonqFeatureDev.follow_up.close_session=No, thanks
7778
amazonqFeatureDev.follow_up.incorrect_source_folder=The folder you chose isn't in your open workspace folder. You can add this folder to your workspace, or choose a folder in your open workspace.

0 commit comments

Comments
 (0)