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

[Bug] Garden exists with 0 exit code on unsupported options and sub-commands #4911

Closed
vvagaytsev opened this issue Aug 2, 2023 · 0 comments · Fixed by #5235
Closed

[Bug] Garden exists with 0 exit code on unsupported options and sub-commands #4911

vvagaytsev opened this issue Aug 2, 2023 · 0 comments · Fixed by #5235
Assignees
Labels
bug devex Developer experience and ease of use. papercut

Comments

@vvagaytsev
Copy link
Collaborator

vvagaytsev commented Aug 2, 2023

Bug

Current Behavior

Case 1.
When garden is executed with an unrecognized option and without any command (e.g. garden --bad) it prints the usage help and exists with code 0.

Case 2.
When garden is executed with an unrecognized sub-command (e.g. garden run bad) it prints the usage help and exists with code 0.

Expected behavior

In both cases above garden should exit with code 1 if an unrecognized option or sub-command is passed.

Reproducible example

Run these commands:

# Unrecognized option:
> garden --bad
# usage output omitted
# ...
> echo $?
0   # <- this is wrong

# Unrecognized sub-command:
> garden delete bad
# usage output omitted
# ...
> echo $?
0   # <- this is wrong

Workaround

No

Suggested solution(s)

Implement checks for garden's options inspection and exit with code 1 on unrecognized options.

Note! The old behaviour for other testing scenarios is correct and must be kept:

# Unrecognized (invalid) command:
> garden bad
# usage output omitted
# ...
> echo $?
1

# Unrecognized (invalid) _command_ option:
> garden deploy --bad
# usage output omitted
# ...
> echo $?
1

# Recognized (valid) option:
> garden --help
# usage output omitted
# ...
> echo $?
0

Make sure we have the tests for the scenarios above. Please implement the missing test scenarios if any.

Additional context

This comes from the discussion started in #4868.

Your environment

  • OS: all
  • How I'm running Kubernetes: does not matter

garden version 0.13.9
garden version 0.12.63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug devex Developer experience and ease of use. papercut
Projects
None yet
1 participant