databricks / dbt-databricks

A dbt adapter for Databricks.
https://databricks.com
Apache License 2.0
211 stars 112 forks source link

dbt-databricks 1.6.latest is passing (exit 0) on `debug` even though the token is invalid #450

Closed jeremyyeo closed 11 months ago

jeremyyeo commented 11 months ago

Describe the bug

If we have an invalid databricks token, the dbt debug command seems to still be passing (on aggregate and exit 0) when using dbt-databricks while in previous versions, an Exception was raised instead.

Steps To Reproduce

Not much to do here, just setup a profiles.yml with an invalid token:

# ~/.dbt/profiles.yml
databricks:
  target: default
  outputs:
    default:
      type: databricks
      schema: dbt_jyeo
      host: dbc-c7c89cba-cf9b.cloud.databricks.com
      token: kablamo
      http_path: /sql/1.0/endpoints/8bce9401ba8e2755

# dbt_project.yml
name: my_dbt_project
profile: databricks
config-version: 2
version: 1.0

models:
  my_dbt_project:
    +materialized: table

And then debug with versions 1.6 and 1.5.

(venv_dbt_1.5.latest) ➜  dbt-basic git:(main) ✗ dbt --version                          
Core:
  - installed: 1.5.6
  - latest:    1.6.3 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - databricks: 1.5.5 - Update available!
  - bigquery:   1.5.5 - Update available!
  - snowflake:  1.5.3 - Update available!
  - spark:      1.5.2 - Update available!

  At least one plugin is out of date or incompatible with dbt-core.
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

(venv_dbt_1.5.latest) ➜  dbt-basic git:(main) ✗ dbt debug            
01:42:51  Running with dbt=1.5.6
01:42:51  dbt version: 1.5.6
01:42:51  python version: 3.9.13
01:42:51  python path: /Users/jeremy/src/dbt-basic/venv_dbt_1.5.latest/bin/python
01:42:51  os info: macOS-13.4.1-x86_64-i386-64bit
01:42:51  Using profiles.yml file at /Users/jeremy/.dbt/profiles.yml
01:42:51  Using dbt_project.yml file at /Users/jeremy/src/dbt-basic/dbt_project.yml
01:42:51  Configuration:
01:42:52    profiles.yml file [OK found and valid]
01:42:52    dbt_project.yml file [OK found and valid]
01:42:52  Required dependencies:
01:42:52   - git [OK found]

01:42:52  Connection:
01:42:52    host: dbc-c7c89cba-cf9b.cloud.databricks.com
01:42:52    http_path: /sql/1.0/endpoints/8bce9401ba8e2755
01:42:52    schema: dbt_jyeo
01:42:52  Registered adapter: databricks=1.5.5
01:42:54  databricks-sql-connector adapter: Error during request to server: : Invalid access token.: {"method": "OpenSession", "session-id": null, "query-id": null, "http-code": 403, "error-message": ": Invalid access token.", "original-exception": "", "no-retry-reason": "non-retryable error", "bounded-retry-delay": null, "attempt": "1/30", "elapsed-seconds": "1.778109073638916/900.0"}
01:42:54    Connection test: [ERROR]

01:42:54  1 check failed:
01:42:54  dbt was unable to connect to the specified database.
The database returned the following error:

  >Runtime Error
  Database Error
    Error during request to server: : Invalid access token.

Check your database credentials and try again. For more information, visit:
https://docs.getdbt.com/docs/configure-your-profile
(venv_dbt_1.6.latest) ➜  dbt-basic git:(main) ✗ dbt --version                
Core:
  - installed: 1.6.3
  - latest:    1.6.3 - Up to date!

Plugins:
  - databricks: 1.6.4 - Up to date!
  - bigquery:   1.6.5 - Up to date!
  - snowflake:  1.6.2 - Up to date!
  - spark:      1.6.0 - Up to date!

(venv_dbt_1.6.latest) ➜  dbt-basic git:(main) ✗ dbt debug    
01:44:00  Running with dbt=1.6.3
01:44:00  dbt version: 1.6.3
01:44:00  python version: 3.9.13
01:44:00  python path: /Users/jeremy/src/dbt-basic/venv_dbt_1.6.latest/bin/python
01:44:00  os info: macOS-13.4.1-x86_64-i386-64bit
01:44:01  Using profiles dir at /Users/jeremy/.dbt
01:44:01  Using profiles.yml file at /Users/jeremy/.dbt/profiles.yml
01:44:01  Using dbt_project.yml file at /Users/jeremy/src/dbt-basic/dbt_project.yml
01:44:01  adapter type: databricks
01:44:01  adapter version: 1.6.4
01:44:01  Configuration:
01:44:01    profiles.yml file [OK found and valid]
01:44:01    dbt_project.yml file [OK found and valid]
01:44:01  Required dependencies:
01:44:01   - git [OK found]

01:44:01  Connection:
01:44:01    host: dbc-c7c89cba-cf9b.cloud.databricks.com
01:44:01    http_path: /sql/1.0/endpoints/8bce9401ba8e2755
01:44:01    schema: dbt_jyeo
01:44:01  Registered adapter: databricks=1.6.4
01:44:03    Connection test: [ERROR]

01:44:03  All checks passed!

^ All checks passed for some reason.

Expected behavior

I think we want to error as we did in 1.5.

Screenshots and log output

If applicable, add screenshots or log output to help explain your problem.

System information

The output of dbt --version: See above.

The operating system you're using: macOS

The output of python --version:

Python 3.9.13

Additional context

benc-db commented 11 months ago

Will investigate, thanks for reporting.

benc-db commented 11 months ago

My investigation shows the issue to be in dbt-core, and should be fixed by this: https://github.com/dbt-labs/dbt-core/commit/b514e4c24971b8b589b6559458a59bca9d2b6807

benc-db commented 11 months ago

Closing as issue is in core, and not much we can do here. If they haven't already, you may want to ask them to backport this fix.