question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"cdk diff" returns error code 1

See original GitHub issue

Calling cdk difffrom NPM fails because the command does not return 0.

package.json

  "scripts": {
    "diff": "cdk diff"    
  }

Running npm run diff fails.

cdk diff; echo $?shows the error code returned is 1.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

13reactions
eladbcommented, Mar 28, 2019

As much as this is a nice a pure way to express that “there is a diff”. I doesn’t seem like that’s what people expect. This is the 3rd or 4th time someone fell into this little pit. I’d argue that we can add a flag --fail for those brave souls who are interested to use cdk diff to check if there is a diff and change the default behavior to what people most expect.

5reactions
timwelchcommented, Jan 5, 2021

When running through a pipeline (i.e. Jenkins), I’d actually expect a different result. If there’s a diff that’s cool and I want to move on to the next stage of the pipeline and deploy it, so an exit code of 1 is actually not good here. If there’s an ERROR, like someone committed bad code to the repo which causes cdk diff to actually throw an error, like invalid syntax or anything that would cause it to NOT deploy… That seems like an error code of 1 or 2 or something else, no?

Expected results would be:

exit 0 – No diff and the expected pre-compilation or whatever didn’t find any errors in synthesizing. exit 1 – You have an error, I could not synth due to any number of reasons, invalid syntax, etc etc. exit 2 – Synth worked, code looks clean, and there is a diff that I would apply if you were to deploy.

With those, I can create really functional pipeline steps. With exit 0, I can skip the deploy stage entirely because there’s no need. With exit 1, I can shoot an email to the Dev who last committed to the repo and broke the pipeline with bad syntax or something. With exit 2, I know something changed and I move on to apply it.

With either a blanket return of 0, or forcing me now to use “|| true” … I actually get nothing. I end up having to create an Approval stage where the pipeline sits until someone looks at the output of the Diff to see if it was a real change or if the CDK is now broken and wouldn’t deploy if we wanted it to.

Suggestions / Thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

"cdk diff" returns error code 1 · Issue #2111 - GitHub
Calling cdk diff from NPM fails because the command does not return 0. ... Running npm run diff fails. cdk diff; echo $?...
Read more >
What are the returned status code of `cdk diff` - Stack Overflow
The documentation for CDK diff states the following: --fail Fail with exit code 1 in case of diff [boolean] [default: false].
Read more >
Troubleshooting common AWS CDK issues
This topic describes how to troubleshoot the following issues with the AWS CDK.
Read more >
awslabs/aws-cdk - Gitter
I'm using Java/Scala so I'm not really sure if having just an updated cdk command line is enough or if I also need...
Read more >
AWS CDK Toolkit - npm
This command returns non-zero if any differences are found. $ # Diff against the currently deployed stack $ cdk diff --app='node bin/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found