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(CLI): diff --template crashes #29896

Merged
merged 7 commits into from
Apr 24, 2024
Merged

fix(CLI): diff --template crashes #29896

merged 7 commits into from
Apr 24, 2024

Conversation

comcalvi
Copy link
Contributor

@comcalvi comcalvi commented Apr 18, 2024

Issue # (if applicable)

Closes #29890.

Reason for this change

cdk diff crashes with --template.

Description of changes

The addition of changeset logic had a leftover refactor that should not have been leftover (trying to pass a template directly instead of a stack artifact). Removes changeset creation code from fixed template mode, which should never create a changeset, and adds a unit test for fixed template diffs so we don't break this in the future.

Description of how you validated changes

unit tests + manual testing. CLI integ tests will be added in a follow-up PR.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team April 18, 2024 21:57
@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Apr 18, 2024
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 18, 2024
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.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@comcalvi comcalvi added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Apr 18, 2024
@@ -51,6 +51,10 @@ export function fullDiff(
isImport?: boolean,
): types.TemplateDiff {

if (!currentTemplate || !newTemplate) {
throw new Error('trying to diff a template that is not defined');
Copy link
Contributor

Choose a reason for hiding this comment

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

What does that error even mean? How do I fix this?

};

// THEN
expect(() => fullDiff(currentTemplate, newTemplate)).toThrow(/trying to diff a template that is not defined/);
Copy link
Contributor

Choose a reason for hiding this comment

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

From this code I can get why there is this check. But how would an actual user end up with this? How can they fix it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A user would never end up with this. I added it because diff is design to work on arbitrary json objects, but it achieves this by typing things as any, which allows undefined. undefined breaks it though, so I figured we could be a bit more defensive with that. It's not doing anything useful though, it's just moving the crash earlier, so I can remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason this change got through is it looked innocuous and it didn't break any tests, because we had just never tested fixed-template diffs before

@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@aws-cdk-automation aws-cdk-automation added pr/do-not-merge This PR should not be merged at this time. pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested and removed pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Apr 19, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 19, 2024 20:15

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

@aws-cdk-automation aws-cdk-automation removed the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Apr 19, 2024
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.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation removed the pr/do-not-merge This PR should not be merged at this time. label Apr 19, 2024
@comcalvi comcalvi added the pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested label Apr 22, 2024
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 22, 2024 15:22

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

@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Apr 24, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

mergify bot commented Apr 24, 2024

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: d9d29b2
  • 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 466f170 into main Apr 24, 2024
11 of 12 checks passed
@mergify mergify bot deleted the comcalvi/diff-crash branch April 24, 2024 01:45
Copy link
Contributor

mergify bot commented Apr 24, 2024

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

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. contribution/core This is a PR that came from AWS. effort/medium Medium work item – several days of effort p1 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cli): cdk diff --template >=2.133.0 crashes
4 participants