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

zbctl uses incorrect exit status 0 on error #3993

Closed
grexe opened this issue Mar 5, 2020 · 7 comments
Closed

zbctl uses incorrect exit status 0 on error #3993

grexe opened this issue Mar 5, 2020 · 7 comments
Assignees
Labels
kind/bug Categorizes an issue or PR as a bug

Comments

@grexe
Copy link

grexe commented Mar 5, 2020

Describe the bug
When invoking zbctl with invalid arguments, or Zeebe is not running at all, it still exits with code 0, which is wrong and makes it hard to integrate in scripts.

To Reproduce
Issue zbctl when Zeebe is not running, or specify a wrong address.

Expected behavior
Ideally, exit code 64 should be used to indicate wrong parameters used, see https://stackoverflow.com/a/1535733/160799

Environment:

  • OS: MacOS X 10.15.3 (19D76)
  • Zeebe Version: 0.22.1
  • Configuration: n/a
@grexe grexe added the kind/bug Categorizes an issue or PR as a bug label Mar 5, 2020
@MiguelPires
Copy link
Contributor

MiguelPires commented Mar 5, 2020

Hi @grexe. Thanks for reporting this.
When trying to reproduce this with 0.22.1, I was only able to get an erroneous 0 code when running zbctl by itself (with no subcommands). Other errors (either parsing or execution) always showed a 1 code. Can you confirm that any errors result in a 0 code? Maybe it's an OS thing, tomorrow I can ask someone to try to reproduce this on a Mac. The incorrect 0 code I'm getting when I run zbctl without any subcommand or flag is already fixed in the latest 0.23.0-alpha2 version, since we upgraded to cobra's 0.0.6 version (which contains this fix spf13/cobra#922).
Currently, I think Cobra doesn't distinguish between errors so there's no nice distinguish a parsing errors from an execution one. The one exception to this is the case where the parsing failure is due to a missing subcommand, that we can detect. I'll have a deeper look tomorrow to check if there's some way we can improve on this

@grexe
Copy link
Author

grexe commented Mar 6, 2020

Here's a concrete case where it should return an error status but exits with 0:

❯ zbctl --insecure status

Error: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 127.0.0.1:26500: connect: connection refused"
Usage:
…

❯ echo $?
0

@MiguelPires
Copy link
Contributor

Hey @korthout, can you try to reproduce this on your machine when you have a spare moment?

@korthout
Copy link
Member

korthout commented Mar 9, 2020

@MiguelPires @grexe I've tried to reproduce this on macOS 10.15.3 with Zeebe v 0.22.1 (see: https://github.com/zeebe-io/zeebe/releases/tag/0.22.1), but I've not been able to get the erroneous 0 exit code.

  ↳ ~/Downloads/zeebe-broker-0.22.1/bin/zbctl.darwin --insecure status
Error: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp 127.0.0.1:26500: connect: connection refused"
Usage:
...

  ↳ echo $?
1

@grexe
Copy link
Author

grexe commented Mar 9, 2020

oh no, as I feared and forgot to mention (sorry for that!), it's the npm wrapper I use that causes the error:

  • with original bin/zbctl from distribution, I get the correct status 1
  • with zbctl from npm, it's always status 0

Will open an issue there, please feel free to close this one.

@MiguelPires
Copy link
Contributor

MiguelPires commented Mar 9, 2020

Ah no worries, I'll close this issue then. Thanks @nico and @grexe

@grexe
Copy link
Author

grexe commented Mar 9, 2020

opened bug in npm wrapper now: camunda-community-hub/zbctl-via-npm#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes an issue or PR as a bug
Projects
None yet
Development

No branches or pull requests

3 participants