Skip to content
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(yaml-cfn): do not deserialize year-month-date as strings #13745

Merged
merged 2 commits into from
Mar 30, 2021

Conversation

skinny85
Copy link
Contributor

Currently, we are using the yaml-1.1 schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the core schema from yaml-1.1,
where those are treated as strings, instead of dates.

Fixes #13709


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@skinny85 skinny85 requested a review from RomainMuller March 22, 2021 19:32
@skinny85 skinny85 self-assigned this Mar 22, 2021
@gitpod-io
Copy link

gitpod-io bot commented Mar 22, 2021

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Mar 22, 2021
@@ -54,6 +54,6 @@ const shortForms: yaml_types.Schema.CustomTag[] = [
function parseYamlStrWithCfnTags(text: string): any {
return yaml.parse(text, {
customTags: shortForms,
schema: 'yaml-1.1',
schema: 'core',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But are we sure using the core schema is not going to break other stuff? I.e: is "No" going to be encoded correctly (read: quoted), or is it going to be encoded YAML-1.2-style (which in Yaml 1.1 is an alias for false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I added a test confirming that No is deserialized correctly (as "No", not false).

Let me know if you want to see some more tests of some edge-cases in the YAML handling!

Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709
@skinny85 skinny85 force-pushed the fix/yaml-strings-as-dates branch from 0cdb139 to 40f8067 Compare March 26, 2021 18:17
@skinny85 skinny85 requested a review from RomainMuller March 26, 2021 18:17
@mergify
Copy link
Contributor

mergify bot commented Mar 30, 2021

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).

@mergify
Copy link
Contributor

mergify bot commented Mar 30, 2021

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: accbded
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit ffea818 into aws:master Mar 30, 2021
@skinny85 skinny85 deleted the fix/yaml-strings-as-dates branch March 30, 2021 22:35
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Mar 31, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
hollanddd pushed a commit to hollanddd/aws-cdk that referenced this pull request Aug 26, 2021
Currently, we are using the `yaml-1.1` schema when de-serializing YAML documents,
Unfortunately, this has the side effect of treating unquoted parts of the template like '2010-09-09'
as Date objects, instead of just simple strings.
This has been noted by a customer using the cloudformation-include module,
but I assume a very similar problem exists for other places we parse YAML,
like cloudformation-diff.

Switch to the `core` schema from `yaml-1.1`,
where those are treated as strings, instead of dates.

Fixes aws#13709

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue importing with CfnInclude when template do not have quotes
3 participants