Skip to content

Commit 5ecee55

Browse files
authored
chore(assets): remove empty zip warning (#23193)
I'm pretty sure that the correct fix for the issue this debug text was attempting to help debug was delivered in #22393 Get rid of the warning message, it only serves to confuse. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f5fe69a commit 5ecee55

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

packages/cdk-assets/lib/private/handlers/files.ts

+1-29
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,6 @@ export class FileAssetHandler implements IAssetHandler {
8383
const publishFile = this.asset.source.executable ?
8484
await this.externalPackageFile(this.asset.source.executable) : await this.packageFile(this.asset.source);
8585

86-
// Add a validation to catch the cases where we're accidentally producing an empty ZIP file (or worse,
87-
// an empty file)
88-
if (publishFile.contentType === 'application/zip') {
89-
const fileSize = (await fs.stat(publishFile.packagedPath)).size;
90-
if (fileSize <= EMPTY_ZIP_FILE_SIZE) {
91-
const message = [
92-
'🚨 WARNING: EMPTY ZIP FILE 🚨',
93-
'',
94-
'Zipping this asset produced an empty zip file. We do not know the root cause for this yet, and we need your help tracking it down.',
95-
'',
96-
'Please visit https://github.com/aws/aws-cdk/issues/18459 and tell us:',
97-
'Your OS version, Nodejs version, CLI version, package manager, what the asset is supposed to contain, whether',
98-
'or not this error is reproducible, what files are in your cdk.out directory, if you recently changed anything,',
99-
'and anything else you think might be relevant.',
100-
'',
101-
'The deployment will continue, but it may fail. You can try removing the cdk.out directory and running the command',
102-
'again; let us know if that resolves it.',
103-
'',
104-
'If you meant to produce an empty asset file on purpose, you can add an empty dotfile to the asset for now',
105-
'to disable this notice.',
106-
];
107-
108-
for (const line of message) {
109-
this.host.emitMessage(EventType.FAIL, line);
110-
}
111-
}
112-
}
113-
11486
this.host.emitMessage(EventType.UPLOAD, `Upload ${s3Url}`);
11587

11688
const params = Object.assign({}, {
@@ -299,4 +271,4 @@ async function cached<A, B>(cache: Map<A, B>, key: A, factory: (x: A) => Promise
299271
const fresh = await factory(key);
300272
cache.set(key, fresh);
301273
return fresh;
302-
}
274+
}

packages/cdk-assets/test/files.test.ts

-12
Original file line numberDiff line numberDiff line change
@@ -310,18 +310,6 @@ test('correctly identify asset path if path is absolute', async () => {
310310
expect(true).toBeTruthy(); // No exception, satisfy linter
311311
});
312312

313-
test('empty directory prints failures', async () => {
314-
const progressListener = new FakeListener();
315-
const pub = new AssetPublishing(AssetManifest.fromPath('/emptyzip/cdk.out'), { aws, progressListener });
316-
317-
aws.mockS3.listObjectsV2 = mockedApiResult({ Contents: undefined });
318-
aws.mockS3.upload = mockUpload(); // Should not be hit
319-
320-
await pub.publish();
321-
322-
expect(progressListener.messages).toContainEqual(expect.stringContaining('EMPTY ZIP FILE'));
323-
});
324-
325313
describe('external assets', () => {
326314
let pub: AssetPublishing;
327315
beforeEach(() => {

0 commit comments

Comments
 (0)