-
Notifications
You must be signed in to change notification settings - Fork 4k
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
aws-cdk-notices: CDK Notice being parsed incorrectly causing YAMLSemanticError #33589
Comments
Sorry in advance if this isn't the right place. Not too sure where would be the most appropriate to raise the issue and thought it would be best to raise it here due to the yaml dependency of aws-cdk-lib seemingly being the one that is causing the error. Please let me know if you prefer me to raise in the other relevant repos: |
All good, thanks for raising this @frankpengau looking into it right now |
@frankpengau I cannot reproduce this with a basic, newly created app (via
Thanks! |
Also checked for constructs that use the
Are you using any of these in your app? |
I was facing the same issue while deployment where when the NOTICE was being printed in stdout then the deployment was failing due to parsing error, to bypass this, I modified my Jenkinsfile to execute the command as |
EDIT: nevermind Can you run the above command again with
? I'd like to figure out where the YAML parse is coming from. |
@zain-siddiqui24602 Could you share your dependencies with us and answer some of the questions I posted earlier? |
Hey, I was facing the same issue. I tried setting the notices to false, which disabled the top-level notice; however, it appears that the notices are still coming from a nested structure, so I continue to receive the error. The cdk synth command runs without any problems. My construct contains several StackSets.
error output attached |
@pennyZZZZ Thank you, this is super helpful. Could you please to run this with an extended stack trace and post the full output?
@frankpengau @zain-siddiqui24602 Are you also using I could see this issue occuring when CI=1 npx aws-cdk@2.150.0 synth > template.yaml |
Sorry @mrgrain, still trying to create a full reproduction without involving company private libraries. Custom cdk app with aws-cdk-lib and alpha @aws-cdk libraries using L2 constructs. aws-cdk-lib v2.180.0 Haven't been able to reproduce with Will try and remove sensitive data and publish output for verbose logs for cdk deploy later.
Not using any of the packages listed. |
Have seen it on a repo that extends off constructs for cdk-stacksets, but also have seen it on another cdk app repo that uses L2 constructs for aws-cdk-lib. |
@mrgrain Hey, here is the extended stack trace /app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1856
doc.errors.push(new PlainValue.YAMLSemanticError(item, msg));
^
YAMLSemanticError: Implicit map keys need to be followed by map values
at resolveBlockMapItems (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1856:33)
at Object.resolveMap [as resolve] (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1658:79)
at resolveByTagName (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1430:25)
at resolveTag (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1460:17)
at resolveNodeValue (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1581:23)
at Object.resolveNode (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/resolveSeq-d03cb037.js:1629:15)
at parseContents (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/Document-9b4560a1.js:357:30)
at Document.parse (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/Document-9b4560a1.js:615:5)
at parseDocument (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/index.js:44:37)
at Object.parse (/app/node_modules/aws-cdk-lib/node_modules/yaml/dist/index.js:55:15)
at parseYamlStrWithCfnTags (/app/node_modules/aws-cdk-lib/cloudformation-include/lib/private/yaml-cfn.js:1:1206)
at Object.deserialize (/app/node_modules/aws-cdk-lib/cloudformation-include/lib/private/yaml-cfn.js:1:529)
at Object.readYamlSync (/app/node_modules/aws-cdk-lib/cloudformation-include/lib/file-utils.js:1:494)
at new CfnInclude (/app/node_modules/aws-cdk-lib/cloudformation-include/lib/cfn-include.js:1:1317)
at new CDKBootstrap (/app/src/StackSets/CDKBootstrap.ts:9:5)
at new MyOrgStackSets (/app/src/stack.ts:62:33)
at Object.<anonymous> (/app/src/index.ts:23:1)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Module.m._compile (/app/node_modules/ts-node/src/index.ts:1618:23)
at node:internal/modules/cjs/loader:1699:10
at Object.require.extensions.<computed> [as .ts] (/app/node_modules/ts-node/src/index.ts:1621:12)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at phase4 (/app/node_modules/ts-node/src/bin.ts:649:14)
at bootstrap (/app/node_modules/ts-node/src/bin.ts:95:10)
at main (/app/node_modules/ts-node/src/bin.ts:55:10)
at Object.<anonymous> (/app/node_modules/ts-node/src/bin.ts:800:3)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object.<anonymous> (node:internal/modules/cjs/loader:1699:10)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49 {
source: PlainValue {
error: null,
range: Range { start: 21443, end: 21531 },
valueRange: Range { start: 21443, end: 21531 },
props: [],
type: 'PLAIN',
value: null,
resolved: Scalar {
value: "\x1B[37mNOTICES (What's this? https://github.com/aws/aws-cdk/wiki/CLI-Notices)\x1B[39m",
range: [Array],
type: 'PLAIN'
}
}
} |
Thanks @pennyZZZZ appreciate the details. Can you share the content of this file with us? It seems to be the source of the call, and appears to be a file that's not part of the CDK itself.
|
@mrgrain yeah sure
and the cdk-bootstrap.template.yml is generated by |
Thank you @pennyZZZZ ! When you are running cdk bootstrap --no-notice --show-template @frankpengau @zain-siddiqui24602 Are you doing something similar in your code? |
Hey @mrgrain, thanks for your help—it works perfectly! I just wanted to clarify that the correct flag is |
Thanks @pennyZZZZ Updated my post. While adding |
On CI systems, the CDK CLI tries to avoid writing to `stderr` because there are a couple of CI systems that are commonly configured to fail if any output is written to `stderr`. That means all output, like notices, must go to `stdout`. Some commands (like `cdk synth` or `cdk bootstrap --show-template`) produce usable output on `stdout`, and these are commonly scripted, like piping their output to a file. However, because notices must go to `stdout`, these now interfere with the output of these commands. This needs a more thorough reworking of the CLI output streams, but there is a risk of affecting users who are currently relying on the fact that all output goes to `stdout`. In this PR, we are doing the first steps to solving this situation: - Notices will always go to `stderr`, so that they will never interfere with `stdout` anymore. - We try to detect what CI system we are running on, and we will completely suppress notices *unless* we determine that we are running on a CI system where it is "safe" to write to `sterr` (fail closed). "Safe" in this case means that the CI system doesn't come with an easy to toggle checkbox that makes commands fail based on what they print, instead of their exit codes. The only systems I'm aware of that have this checkbox are "Azure DevOps", and "TeamCity running PowerShell scripts". Even though we know the systems that are "unsafe", we will only show notices on systems known to be "safe". Fixes aws/aws-cdk#33589.
Describe the bug
When running a CDK Deploy, due to the CDK Notice, it seems to be picked up and parsed by YAML?
This causes a YAMLSemanticError to be produced within one of aws-cdk yaml dependencies.
Regression Issue
Last Known Working CDK Version
2.177.0
Expected Behavior
CDK Deploy should not fail on YAMLSemanticError.
Current Behavior
Error Log Output after CDK Deploy:
Reproduction Steps
npx aws-cdk deploy
Possible Solution
Stop CDK notices from being picked up by aws-cdk-lib yaml for parsing.
Additional Information/Context
Have tried using environment variable:
CDK_NOTICES=false
as suggested, but it doesn't ignore it.Ref: https://github.com/aws/aws-cdk/wiki/CLI-Notices#what-if-i-dont-want-notices
CDK CLI Version
2.1000.3
Framework Version
No response
Node.js Version
22.14.0
OS
Amazon Linux 2
Language
TypeScript
Language Version
TypeScript (5.3.3)
Other information
Node 22.14.0 / NPM 10.9.2
The text was updated successfully, but these errors were encountered: