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

debug exit code does not match connection test #3017

Closed
sdebruyn opened this issue Jan 20, 2021 · 3 comments · Fixed by #3018
Closed

debug exit code does not match connection test #3017

sdebruyn opened this issue Jan 20, 2021 · 3 comments · Fixed by #3018
Labels
bug Something isn't working cli

Comments

@sdebruyn
Copy link
Contributor

Describe the bug

When I run dbt debug, I would expect a successful exit code (0) when the connection test succeeds and an error code (>0) when the connection test fails. In 0.18.1 the exit code is always 0, regardless of the result of the test.

Steps To Reproduce

  1. Make sure your profile works
  2. Run dbt debug (connection test should succeed)
  3. Run echo $? - observe that the output is 0
  4. Mess up your profile (e.g. change the port to an invalid one)
  5. Run dbt debug (connection test should fail)
  6. Run echo $? - observe that the output is still 0

Expected behavior

A strictly positive exit code when the connection test fails.

Screenshots and log output

Mentioned in repro

System information

Any database

The output of dbt --version:

installed version: 0.18.1
   latest version: 0.18.1

Up to date!

Plugins:
  - sqlserver: 0.18.1
  - bigquery: 0.18.1
  - snowflake: 0.18.1
  - postgres: 0.18.1
  - redshift: 0.18.1

**The operating system you're using: Debian Buster

The output of python --version:
Python 3.8.7

@sdebruyn sdebruyn added bug Something isn't working triage labels Jan 20, 2021
@jtcohen6 jtcohen6 added cli and removed triage labels Jan 20, 2021
@jtcohen6
Copy link
Contributor

@sdebruyn I agree. If dbt debug manages to detect an error in your path, project, connection profile—or that you're not running from a dbt project at all—it feels like it should return 1 ("handled error") as the exit code instead of 0. I imagine could be useful for plugin maintainers who want to check various connection methods in CI (e.g. dbt-msft/dbt-sqlserver#65).

Is this a change you'd be interested in contributing?

@sdebruyn
Copy link
Contributor Author

@jtcohen6
Copy link
Contributor

That sounds right to me! We define an ExitCodes enum here:
https:/fishtown-analytics/dbt/blob/1f927a374c8bd52a12a20d892fed9d59cffd04f4/core/dbt/utils.py#L32-L35

(ModelError sounds narrow; we might consider renaming someday to something more generic like HandledError.)

I think you'd want to pull that into task/debug.py, and conclude the run method by calling sys.exit() with the appropriate enum value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants