Skip to content

Commit

Permalink
chore(assets): remove empty zip warning (#23193)
Browse files Browse the repository at this point in the history
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*
  • Loading branch information
rix0rrr committed Dec 2, 2022
1 parent f5fe69a commit 5ecee55
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
30 changes: 1 addition & 29 deletions packages/cdk-assets/lib/private/handlers/files.ts
Expand Up @@ -83,34 +83,6 @@ export class FileAssetHandler implements IAssetHandler {
const publishFile = this.asset.source.executable ?
await this.externalPackageFile(this.asset.source.executable) : await this.packageFile(this.asset.source);

// Add a validation to catch the cases where we're accidentally producing an empty ZIP file (or worse,
// an empty file)
if (publishFile.contentType === 'application/zip') {
const fileSize = (await fs.stat(publishFile.packagedPath)).size;
if (fileSize <= EMPTY_ZIP_FILE_SIZE) {
const message = [
'🚨 WARNING: EMPTY ZIP FILE 🚨',
'',
'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.',
'',
'Please visit https://github.com/aws/aws-cdk/issues/18459 and tell us:',
'Your OS version, Nodejs version, CLI version, package manager, what the asset is supposed to contain, whether',
'or not this error is reproducible, what files are in your cdk.out directory, if you recently changed anything,',
'and anything else you think might be relevant.',
'',
'The deployment will continue, but it may fail. You can try removing the cdk.out directory and running the command',
'again; let us know if that resolves it.',
'',
'If you meant to produce an empty asset file on purpose, you can add an empty dotfile to the asset for now',
'to disable this notice.',
];

for (const line of message) {
this.host.emitMessage(EventType.FAIL, line);
}
}
}

this.host.emitMessage(EventType.UPLOAD, `Upload ${s3Url}`);

const params = Object.assign({}, {
Expand Down Expand Up @@ -299,4 +271,4 @@ async function cached<A, B>(cache: Map<A, B>, key: A, factory: (x: A) => Promise
const fresh = await factory(key);
cache.set(key, fresh);
return fresh;
}
}
12 changes: 0 additions & 12 deletions packages/cdk-assets/test/files.test.ts
Expand Up @@ -310,18 +310,6 @@ test('correctly identify asset path if path is absolute', async () => {
expect(true).toBeTruthy(); // No exception, satisfy linter
});

test('empty directory prints failures', async () => {
const progressListener = new FakeListener();
const pub = new AssetPublishing(AssetManifest.fromPath('/emptyzip/cdk.out'), { aws, progressListener });

aws.mockS3.listObjectsV2 = mockedApiResult({ Contents: undefined });
aws.mockS3.upload = mockUpload(); // Should not be hit

await pub.publish();

expect(progressListener.messages).toContainEqual(expect.stringContaining('EMPTY ZIP FILE'));
});

describe('external assets', () => {
let pub: AssetPublishing;
beforeEach(() => {
Expand Down

0 comments on commit 5ecee55

Please sign in to comment.