-
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
when using npm run cdk ...
parameters are eaten by npm unless npm run cdk -- ...
is used.
#27209
Comments
This is a pretty clear issue. Thanks for reporting. |
Doing a deep dive on this, there looks to be a deeper problem here. The actual CLI call into diff is made at aws-cdk/packages/aws-cdk/lib/cli.ts Line 485 in a2a4f68
This is partly controlled by the feature flag aws-cdk:enabledDiffNoFail
This defaults to 'true'. This gets a weird ternary dance in the configuration of fail: args.fail != null ? args.fail : !enableDiffNoFail, I'm assuming that passing I don't know how falsy/truthy null vs other values can be in Typescript, but it appears that the rest of the codebase compares against |
Actually, this flag has a lot of UX issues! I might file separate issues for these, but I'll just make sure to record them here for reference. Why is a nonzero exit code not the default if
$ ./node_modules/.bin/cdk diff --fail
[omitted, no diff printed here]
The security token included in the request is expired
$ echo $?
1 Even passing a non-existing flag results in the same exit code (reported): $ ./node_modules/.bin/cdk diff --wtf
[no mention of the `--wtf` flag here!]
The security token included in the request is expired This means anyone who wants to react to an actual diff has to parse the output instead of checking the exit code. An exit code of 1 could mean basically anything, making the flag almost completely useless.
|
What a crock. It turns out that
The end result is that You can see the core of the issue by observing that the command is printed without the flag:
|
|
I'm going to leave this open so that we have a tracking issue at least. This may be a known interaction with npm, but we should at least be aware of it since we do suggest the use of |
--fail
, --fail=true
, and --fail=false
all succeed when there's a diffnpm run cdk ...
parameters are eaten by npm unless npm run cdk -- ...
is used.
Describe the bug
cdk diff --fail
doesn't do anything, whether it's set totrue
,false
, or nothing.Expected Behavior
--fail
should work exactly likegit diff --exit-code
- if there is a diff, the exit code should be non-zero.Current Behavior
The exit code is always zero, making the flag useless.
Reproduction Steps
See log below.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.93.0 (build 724bd01)
Framework Version
No response
Node.js Version
v18.17.1
OS
NixOS
Language
Typescript
Language Version
5.2.2
Other information
Log:
The text was updated successfully, but these errors were encountered: