Skip to content

Commit 8401201

Browse files
authored
Merge pull request aws#4757 from laileni-aws/feature/proactivesub
codewhisperer: telemetry(requestHeaders property) and error handling for uploadArtifactS3Url
2 parents dc531cd + ce86a65 commit 8401201

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

packages/core/src/codewhisperer/client/user-service-2.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,10 @@
603603
"members": {
604604
"uploadId": { "shape": "UploadId" },
605605
"uploadUrl": { "shape": "PreSignedUrl" },
606-
"kmsKeyArn": { "shape": "ResourceArn" }
606+
"kmsKeyArn": { "shape": "ResourceArn" },
607+
"requestHeaders": {
608+
"shape": "RequestHeaders"
609+
}
607610
}
608611
},
609612
"CursorState": {
@@ -1142,6 +1145,27 @@
11421145
"min": 0,
11431146
"pattern": "arn:([-.a-z0-9]{1,63}:){2}([-.a-z0-9]{0,63}:){2}([a-zA-Z0-9-_:/]){1,1023}"
11441147
},
1148+
"RequestHeaderKey": {
1149+
"type": "string",
1150+
"max": 64,
1151+
"min": 1
1152+
},
1153+
"RequestHeaderValue": {
1154+
"type": "string",
1155+
"max": 256,
1156+
"min": 1
1157+
},
1158+
"RequestHeaders": {
1159+
"type": "map",
1160+
"key": {
1161+
"shape": "RequestHeaderKey"
1162+
},
1163+
"value": {
1164+
"shape": "RequestHeaderValue"
1165+
},
1166+
"max": 16,
1167+
"min": 1
1168+
},
11451169
"ResourceNotFoundException": {
11461170
"type": "structure",
11471171
"required": ["message"],

packages/core/src/codewhisperer/service/securityScanHandler.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,18 @@ export async function uploadArtifactToS3(fileName: string, resp: CreateUploadUrl
225225
headersObj['x-amz-server-side-encryption-aws-kms-key-id'] = resp.kmsKeyArn
226226
}
227227

228-
const response = await request.fetch('PUT', resp.uploadUrl, {
229-
body: readFileSync(fileName),
230-
headers: headersObj,
231-
}).response
232-
getLogger().debug(`StatusCode: ${response.status}, Text: ${response.statusText}`)
228+
try {
229+
const response = await request.fetch('PUT', resp.uploadUrl, {
230+
body: readFileSync(fileName),
231+
headers: resp?.requestHeaders ?? headersObj,
232+
}).response
233+
getLogger().debug(`StatusCode: ${response.status}, Text: ${response.statusText}`)
234+
} catch (error) {
235+
getLogger().error(
236+
`Amazon Q is unable to upload workspace artifacts to Amazon S3 for security scans. For more information, see the Amazon Q documentation or contact your network or organization administrator.`
237+
)
238+
throw new Error(
239+
`Amazon Q is unable to upload workspace artifacts to Amazon S3 for security scans. For more information, see the [Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/security_iam_manage-access-with-policies.html) or contact your network or organization administrator.`
240+
)
241+
}
233242
}

0 commit comments

Comments
 (0)