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): format of tags in cdk.json is not validated #21050

Merged
merged 3 commits into from
Jul 8, 2022
Merged

fix(cli): format of tags in cdk.json is not validated #21050

merged 3 commits into from
Jul 8, 2022

Conversation

SydneyUni-Jim
Copy link
Contributor

@SydneyUni-Jim SydneyUni-Jim commented Jul 8, 2022

If tags is present in cdk.json, validate that it is an array of objects, and each object has a Tag string and a Value string. If tags is not structurally valid cdk bootstrap and cdk deploy fail with an error.

tags must be an array of { Tag: string, Value: string } objects

There is no attempt to validate the strings of each Tag and Value beyond that they are strings.

closes #20854


All Submissions:

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 Jul 8, 2022

@github-actions github-actions bot added bug This issue is a bug. effort/small Small work item – less than a day of effort p1 labels Jul 8, 2022
@aws-cdk-automation aws-cdk-automation requested a review from a team July 8, 2022 06:13
If tags is present in cdk.json, validate that it is an array of objects, and each object has a Tag string and a Value string.
@SydneyUni-Jim
Copy link
Contributor Author

As far as I can read, my tests are passing.

aws-cdk: PASS test/util/tags.test.js
aws-cdk: =============================== Coverage summary ===============================
aws-cdk: Statements   : 80.57% ( 3567/4427 )
aws-cdk: Branches     : 69.32% ( 1589/2292 )
aws-cdk: Functions    : 82.75% ( 734/887 )
aws-cdk: Lines        : 81.17% ( 3415/4207 )
aws-cdk: ================================================================================
aws-cdk: Test Suites: 59 passed, 59 total
aws-cdk: Tests:       501 passed, 501 total
aws-cdk: Snapshots:   0 total
aws-cdk: Time:        15.175 s
aws-cdk: Ran all test suites.
aws-cdk: Tests successful. Total time (20.8s) | /codebuild/output/src109426043/src/github.com/aws/aws-cdk/node_modules/jest/bin/jest.js (20.7s)
aws-cdk: Done in 94.47s.

It is this that is failing. I don't understand how the two might be connected.

@aws-cdk/integ-runner: FAIL test/runner/snapshot-test-runner.test.js
@aws-cdk/integ-runner:   ● IntegTest runSnapshotTests › with defaults and diff
@aws-cdk/integ-runner:     Cannot read integ manifest 'test/test-data/test-with-snapshot.integ.snapshot/manifest.json': Unexpected end of JSON input
@aws-cdk/integ-runner:       32 |
@aws-cdk/integ-runner:       33 |     } catch (e) {
@aws-cdk/integ-runner:     > 34 |       throw new Error(`Cannot read integ manifest '${fileName}': ${e.message}`);
@aws-cdk/integ-runner:          |             ^
@aws-cdk/integ-runner:       35 |     }
@aws-cdk/integ-runner:       36 |   }
@aws-cdk/integ-runner:       37 |
@aws-cdk/integ-runner:       at Function.fromFile (lib/runner/private/cloud-assembly.ts:34:13)
@aws-cdk/integ-runner:       at Function.fromPath (lib/runner/private/cloud-assembly.ts:51:37)
@aws-cdk/integ-runner:       at IntegSnapshotRunner.readAssembly (lib/runner/snapshot-test-runner.ts:223:45)
@aws-cdk/integ-runner:       at IntegSnapshotRunner.testSnapshot (lib/runner/snapshot-test-runner.ts:29:35)
@aws-cdk/integ-runner:       at Object.<anonymous> (test/runner/snapshot-test-runner.test.ts:108:31)
@aws-cdk/integ-runner: =============================== Coverage summary ===============================
@aws-cdk/integ-runner: Statements   : 80.82% ( 565/699 )
@aws-cdk/integ-runner: Branches     : 70.37% ( 361/513 )
@aws-cdk/integ-runner: Functions    : 80.95% ( 102/126 )
@aws-cdk/integ-runner: Lines        : 80.92% ( 543/671 )
@aws-cdk/integ-runner: ================================================================================
@aws-cdk/integ-runner: Test Suites: 1 failed, 7 passed, 8 total
@aws-cdk/integ-runner: Tests:       1 failed, 58 passed, 59 total
@aws-cdk/integ-runner: Snapshots:   0 total
@aws-cdk/integ-runner: Time:        4.402 s

rix0rrr
rix0rrr previously approved these changes Jul 8, 2022
@mergify mergify bot dismissed rix0rrr’s stale review July 8, 2022 07:51

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Jul 8, 2022

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: 4d30993
  • 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 8e6a387 into aws:main Jul 8, 2022
@mergify
Copy link
Contributor

mergify bot commented Jul 8, 2022

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

@SydneyUni-Jim SydneyUni-Jim deleted the issue-20854 branch July 8, 2022 09:11
daschaa pushed a commit to daschaa/aws-cdk that referenced this pull request Jul 9, 2022
If tags is present in cdk.json, validate that it is an array of objects, and each object has a Tag string and a Value string. If tags is not structurally valid `cdk bootstrap` and `cdk deploy` fail with an error.

`tags must be an array of { Tag: string, Value: string } objects`

There is no attempt to validate the strings of each Tag and Value beyond that they are strings.

closes aws#20854 

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
kaizencc added a commit that referenced this pull request Jul 11, 2022
mergify bot pushed a commit that referenced this pull request Jul 11, 2022
…ed" (#21092)

Reverts #21050

It breaks the CLI integ tests that get run on our internal pipelines. The error message is `Error: tags must be an array of { Tag: string, Value: string } objects`, which comes from the `validateTags` method in #21050. The test runs `cdk deploy --tag key=value` which I was able to test on my own account to verify that that is a valid way of adding tags to a stack.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(cli): format of tags in cdk.json is not validated, easy to get wrong
3 participants