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(cfnspec): incorrectly handling array result from jsondiff #23795

Merged
merged 2 commits into from
Jan 23, 2023

Conversation

kaizencc
Copy link
Contributor

We are getting an error when updating the cfnspec:

Error: Unexpected array diff entry: [" "]

We are using json-diff to calculate diff entries, and expect that each entry is a 2-tuple array. Indeed, the docs say this. Turns out, this is only true when supplying the --full option.
With --full, the output for equivalent entries is [' ', 1]. Without --full, the output for equivalent entries is [' '].

I considered that this might be a bug/breaking change in json-diff, but I did some spelunking and this is behavior that is codified in tests that haven't been changed in 11 years: https://github.com/andreyvit/json-diff/blob/35582a9d19f8b0b2773360d67937e57ce2866781/test/diff_test.coffee#L78

More likely, we were relying on an implicit default to --full that is now turned off, or we have never come across such an issue before (which feels unlikely). I don't think we actually want --full, because we want the difference and that's it. So I've instead handled this case that should be a one-off case.

I have run the update on my own machine and confirm it works as expected, and the output in CHANGELOG.md is correct.


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

@gitpod-io
Copy link

gitpod-io bot commented Jan 23, 2023

@aws-cdk-automation aws-cdk-automation requested a review from a team January 23, 2023 21:27
@github-actions github-actions bot added the p2 label Jan 23, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jan 23, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ef27325
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@kaizencc kaizencc added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Jan 23, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 23, 2023 22:29

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

@mergify
Copy link
Contributor

mergify bot commented Jan 23, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 4a701f1 into main Jan 23, 2023
@mergify mergify bot deleted the conroy/specdiff branch January 23, 2023 22:55
@kaizencc
Copy link
Contributor Author

@Mergifyio backport v1-main

@mergify
Copy link
Contributor

mergify bot commented Jan 23, 2023

backport v1-main

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Jan 23, 2023
We are getting an error when updating the cfnspec:

```bash
Error: Unexpected array diff entry: [" "]
```

We are using `json-diff` to calculate diff entries, and expect that each entry is a 2-tuple array. Indeed, the [docs](https://github.com/andreyvit/json-diff#arrays) say this. Turns out, this is only true when supplying the `--full` option.
With `--full`, the output for equivalent entries is `[' ', 1]`. Without `--full`, the output for equivalent entries is `[' ']`.

I considered that this might be a bug/breaking change in `json-diff`, but I did some spelunking and this is behavior that is codified in tests that haven't been changed in 11 years:  https://github.com/andreyvit/json-diff/blob/35582a9d19f8b0b2773360d67937e57ce2866781/test/diff_test.coffee#L78

More likely, we were relying on an implicit default to `--full` that is now turned off, or we have never come across such an issue before (which feels unlikely). I don't think we actually want `--full`, because we want the difference and that's it. So I've instead handled this case that should be a one-off case.

I have run the update on my own machine and confirm it works as expected, and the output in `CHANGELOG.md` is correct.

----

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

(cherry picked from commit 4a701f1)
mergify bot added a commit that referenced this pull request Jan 24, 2023
#23795) (#23800)

This is an automatic backport of pull request #23795 done by [Mergify](https://mergify.com).


---


<details>
<summary>Mergify commands and options</summary>

<br />

More conditions and actions can be found in the [documentation](https://docs.mergify.com/).

You can also trigger Mergify actions by commenting on this pull request:

- `@Mergifyio refresh` will re-evaluate the rules
- `@Mergifyio rebase` will rebase this PR on its base branch
- `@Mergifyio update` will merge the base branch into this PR
- `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch

Additionally, on Mergify [dashboard](https://dashboard.mergify.com/) you can:

- look at your merge queues
- generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com
</details>
@RomainMuller RomainMuller deleted the conroy/specdiff branch July 4, 2023 08:46
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. p2 pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exempt-test The PR linter will not require test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants