Skip to content

fix(amazonq): fix uploading file method error handling for /doc #5400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Amazon Q /doc: Fix uploading file method throwing incorrect workspace too large error message"
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import software.aws.toolkits.core.utils.warn
import software.aws.toolkits.jetbrains.common.clients.AmazonQCodeGenerateClient
import software.aws.toolkits.jetbrains.common.session.Intent
import software.aws.toolkits.jetbrains.services.amazonqDoc.docServiceError
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.DocGenerationStreamResult
import software.aws.toolkits.jetbrains.services.amazonqDoc.session.ExportDocTaskAssistResultArchiveStreamResult
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.CodeIterationLimitException
Expand All @@ -31,6 +32,7 @@
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.MonthlyConversationLimitError
import software.aws.toolkits.jetbrains.services.amazonqFeatureDev.ZipFileCorruptedException
import software.aws.toolkits.jetbrains.services.cwc.controller.chat.telemetry.getStartUrl
import software.aws.toolkits.resources.message

Check warning on line 35 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/common/util/AmazonQCodeGenService.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

Remove deprecated symbol import
import software.aws.toolkits.telemetry.AmazonqTelemetry
import software.aws.toolkits.telemetry.MetricResult

Expand Down Expand Up @@ -82,7 +84,7 @@
}
}

fun createUploadUrl(conversationId: String, contentChecksumSha256: String, contentLength: Long, uploadId: String):
fun createUploadUrl(conversationId: String, contentChecksumSha256: String, contentLength: Long, uploadId: String, featureName: String? = null):
CreateUploadUrlResponse {
try {
logger.debug { "Executing createUploadUrl with conversationId $conversationId" }
Expand All @@ -104,6 +106,9 @@
logger.warn(e) { "Create UploadUrl failed for request: ${e.requestId()}" }

if (e is ValidationException && e.message?.contains("Invalid contentLength") == true) {
if (featureName?.equals("docGeneration") == true) {
throw docServiceError(message("amazonqDoc.exception.content_length_error"))

Check warning on line 110 in plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/common/util/AmazonQCodeGenService.kt

View workflow job for this annotation

GitHub Actions / qodana

Usage of redundant or deprecated syntax or deprecated symbols

'message(String, vararg Any): String' is deprecated. Use extension-specific localization bundle instead
}
throw ContentLengthException(operation = FeatureDevOperation.CreateUploadUrl.toString(), desc = null, cause = e.cause)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class PrepareDocGenerationState(
config.conversationId,
zipFileChecksum,
zipFileLength,
uploadId
uploadId,
"docGeneration"
)

uploadArtifactToS3(
Expand Down
Loading