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

cdk diff not picking up differences if old/new value is in format x.y.z #15935

Closed
johfer-bd opened this issue Aug 7, 2021 · 4 comments · Fixed by #16050
Closed

cdk diff not picking up differences if old/new value is in format x.y.z #15935

johfer-bd opened this issue Aug 7, 2021 · 4 comments · Fixed by #16050
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI

Comments

@johfer-bd
Copy link

johfer-bd commented Aug 7, 2021

"cdk diff" in the current version (1.117.0 / 2.0.0-rc.16) doesn't pick up differences if the old/new value has a number-like format but actually isn't a number (e.g. 0.31.1)

What did you expect to happen?

I expected the differences are picked up and shown

What actually happened?

I received "There are no differences"

Environment

  • **CDK CLI Version : 2.0.0-rc.16
  • Node.js Version: 14.17.0
  • OS : MacOs
  • Language (Version): TypeScript (4.1.3)
@johfer-bd johfer-bd added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 7, 2021
@johfer-bd
Copy link
Author

Ok, I looked into this and the culprit is this part in the deepEqual function that compares the old and new template:

safeParseFloat(lvalue) === safeParseFloat(rvalue)) {

// allows a numeric 10 and a literal "10" to be equivalent;
  // this is consistent with CloudFormation.
  if ((typeof lvalue === 'string' || typeof rvalue === 'string') &&
      safeParseFloat(lvalue) === safeParseFloat(rvalue)) {
    return true;
  }

In my case lvalue and rvalue are two version strings like "0.31.1-prod" and "0.31.2-prod" which are both parsed into "0.31" (and hence considered equal).

@johfer-bd
Copy link
Author

johfer-bd commented Aug 9, 2021

I think this can be handled as edge case in safeParseFloat which already makes provisions for things like "0.0" but not for "0.1.something", or "1 something", or whatever is parsed by parseFloat into a (finite) number but actually isn't a number.

@johfer-bd johfer-bd changed the title aws-cdk 2.x: cdk diff not picking up various differences cdk diff not picking up differences if old/new value is in format x.y.z Aug 10, 2021
@peterwoodworth peterwoodworth added p1 effort/small Small work item – less than a day of effort package/tools Related to AWS CDK Tools or CLI and removed needs-triage This issue or PR still needs to be triaged. labels Aug 11, 2021
@vincent-turato
Copy link
Contributor

I would like to submit a PR for this. Should be finished tomorrow.

@rix0rrr rix0rrr removed their assignment Aug 12, 2021
@mergify mergify bot closed this as completed in #16050 Sep 9, 2021
mergify bot pushed a commit that referenced this issue Sep 9, 2021
…new value is in format n.n.n (#16050)

"cdk diff" in the current version doesn't pick up differences if the old/new value has a number-like format but actually isn't a number (e.g. 0.31.1)

Example: two version strings like "0.31.1-prod" and "0.31.2-prod" are both parsed into "0.31" (and hence incorrectly considered equal).

Closes #15935. 

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Sep 9, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. effort/small Small work item – less than a day of effort p1 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
4 participants