Skip to content

Commit

Permalink
fix(triggers): errors are shown as list of bytes (#27119)
Browse files Browse the repository at this point in the history
With Triggers a user can invoke a Lambda Function during every stack deployment.

When we migrated the handler code to SDKv3, we overlooked that the return payload from the invoked lambda function is now a `Uint8Array`, and not a string anymore.
In the error case, we attempt to `JSON.parse()` the error payload which then resulted in a list of bytes being returned to the user.

Updated the handler test case to use correct mocks, including returning a payload that is a Uint8Array.

Closes #27113

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored Sep 13, 2023
1 parent eb1d363 commit 07c6775
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 192 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "34.0.0",
"files": {
"1c4fbe52107a02bc3832ff0608df37583b37909cc2fb431f405c157fdc63b2e1": {
"a0c9975917e46ed0aa8a6428132c7b9164aa1ef177f38f962f1def169eddf951": {
"source": {
"path": "asset.1c4fbe52107a02bc3832ff0608df37583b37909cc2fb431f405c157fdc63b2e1",
"path": "asset.a0c9975917e46ed0aa8a6428132c7b9164aa1ef177f38f962f1def169eddf951",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "1c4fbe52107a02bc3832ff0608df37583b37909cc2fb431f405c157fdc63b2e1.zip",
"objectKey": "a0c9975917e46ed0aa8a6428132c7b9164aa1ef177f38f962f1def169eddf951.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand All @@ -27,15 +27,15 @@
}
}
},
"239e1222881873abff6cdef51f8e3c638744b51baa96c81ce6d806f327d47c64": {
"5deea9a1098892456fc282a7590321fe178d26a3ea864fd5c11fa2e392fe574c": {
"source": {
"path": "MyStack.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "239e1222881873abff6cdef51f8e3c638744b51baa96c81ce6d806f327d47c64.json",
"objectKey": "5deea9a1098892456fc282a7590321fe178d26a3ea864fd5c11fa2e392fe574c.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "1c4fbe52107a02bc3832ff0608df37583b37909cc2fb431f405c157fdc63b2e1.zip"
"S3Key": "a0c9975917e46ed0aa8a6428132c7b9164aa1ef177f38f962f1def169eddf951.zip"
},
"Timeout": 900,
"MemorySize": 128,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"version": "34.0.0",
"files": {
"77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754": {
"f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971": {
"source": {
"path": "asset.77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.bundle",
"path": "asset.f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971.bundle",
"packaging": "zip"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip",
"objectKey": "f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971.zip",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
},
"187dc9b0238204b903862ffef4a8cb4b20d9c18d252845731a6a0bfe60114ed7": {
"8592b210c476c91c8b979c0709e8da1bf3a1a5d12ef0bcc8bbbe8ed17ca45378": {
"source": {
"path": "TriggerTestDefaultTestDeployAssert61636546.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "187dc9b0238204b903862ffef4a8cb4b20d9c18d252845731a6a0bfe60114ed7.json",
"objectKey": "8592b210c476c91c8b979c0709e8da1bf3a1a5d12ef0bcc8bbbe8ed17ca45378.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"outputPaths": [
"Messages.0.Body"
],
"salt": "1694456719494"
"salt": "1694604354167"
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
Expand Down Expand Up @@ -215,7 +215,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip"
"S3Key": "f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971.zip"
},
"Timeout": 120,
"Handler": "index.handler",
Expand Down Expand Up @@ -276,7 +276,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip"
"S3Key": "f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971.zip"
},
"Timeout": 120,
"Handler": "index.isComplete",
Expand Down Expand Up @@ -318,7 +318,7 @@
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}"
},
"S3Key": "77997674c0a10fbb65169124ad6c0d7a664b6162ad44f9abfa22fd006b33f754.zip"
"S3Key": "f9eeaca5689691166106a01e96cb24972dd459c0e44c46f71d5a71a351954971.zip"
},
"Timeout": 120,
"Handler": "index.onTimeout",
Expand Down

This file was deleted.

Loading

0 comments on commit 07c6775

Please sign in to comment.