Skip to content

Commit 1593ce8

Browse files
authored
add error mapping for lambda bundling into an empty zip (#2297)
* add error mapping for lambda bundling into an empty zip * change error to fault * update test
1 parent d66ab17 commit 1593ce8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.changeset/brave-walls-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
add error mapping for lambda bundling into an empty zip

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,12 @@ npm error enoent`,
653653
errorName: 'LambdaMaxSizeExceededError',
654654
expectedDownstreamErrorMessage: undefined,
655655
},
656+
{
657+
errorMessage: `Error: some-stack failed: InvalidParameterValueException: Uploaded file must be a non-empty zip`,
658+
expectedTopLevelErrorMessage: 'Lambda bundled into an empty zip',
659+
errorName: 'LambdaEmptyZipFault',
660+
expectedDownstreamErrorMessage: undefined,
661+
},
656662
];
657663

658664
void describe('invokeCDKCommand', { concurrency: 1 }, () => {

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ export class CdkErrorMapper {
245245
errorName: 'LambdaMaxSizeExceededError',
246246
classification: 'ERROR',
247247
},
248+
{
249+
errorRegex:
250+
/InvalidParameterValueException: Uploaded file must be a non-empty zip/,
251+
humanReadableErrorMessage: 'Lambda bundled into an empty zip',
252+
resolutionMessage: `Try removing '.amplify/artifacts' then running the command again. If it still doesn't work, see https://github.com/aws/aws-cdk/issues/18459 for more methods.`,
253+
errorName: 'LambdaEmptyZipFault',
254+
classification: 'FAULT',
255+
},
248256
{
249257
errorRegex:
250258
/User:(.*) is not authorized to perform: lambda:GetLayerVersion on resource:(.*) because no resource-based policy allows the lambda:GetLayerVersion action/,
@@ -519,4 +527,5 @@ export type CDKDeploymentError =
519527
| 'SecretNotSetError'
520528
| 'SyntaxError'
521529
| 'GetLambdaLayerVersionError'
530+
| 'LambdaEmptyZipFault'
522531
| 'LambdaMaxSizeExceededError';

0 commit comments

Comments
 (0)