-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ec2): Throw error on empty InitFile content (#13009) #13119
Conversation
Validate InitFile content to catch error during synth instead of deploy. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@@ -206,6 +206,12 @@ describe('InitFile', () => { | |||
}); | |||
}); | |||
|
|||
test('empty content string throws error', () => { | |||
expect(() => { | |||
ec2.InitFile.symlink('/tmp/foo', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you changed fromString
and are you testing symlink
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, fixed.
@@ -327,6 +327,9 @@ export abstract class InitFile extends InitElement { | |||
* Use a literal string as the file content | |||
*/ | |||
public static fromString(fileName: string, content: string, options: InitFileOptions = {}): InitFile { | |||
if (!content) { | |||
throw new Error('Content was empty'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be more descriptive, at least referencing the file that was trying to be created. Also, we like our error messages to suggest a clear path forward.
How about:
InitFile ${fileName}: cannot create empty file. Please supply at least one character of content.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, fixed.
Pull request has been modified.
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Validate InitFile content to catch error during synth instead of deploy. Fixes issue #13009
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license