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

[CT-2852] [v1.6 pre-regression] dbt show swallows database errors #8166

Closed
jtcohen6 opened this issue Jul 20, 2023 · 3 comments · Fixed by #8237
Closed

[CT-2852] [v1.6 pre-regression] dbt show swallows database errors #8166

jtcohen6 opened this issue Jul 20, 2023 · 3 comments · Fixed by #8237
Assignees
Labels
bug Something isn't working pre-regression Regression not yet in a stable release

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jul 20, 2023

Previous behavior (v1.5)

$ dbt show --inline 'slect asdlkjfsld;j'
12:33:08  Running with dbt=1.5.2
12:33:08  Registered adapter: postgres=1.5.2
12:33:08  Unable to do partial parsing because of a version mismatch
12:33:09  Found 7 models, 0 tests, 0 snapshots, 0 analyses, 307 macros, 0 operations, 0 seed files, 0 sources, 0 exposures, 0 metrics, 1 group
12:33:09
12:33:09  Concurrency: 5 threads (target='postgres')
12:33:09
12:33:09  Encountered an error:
Runtime Error
  Database Error in sql operation inline_query (from remote system.sql)
    syntax error at or near "slect"
    LINE 2: slect asdlkjfsld;j
            ^

Current behavior (v1.6.0rc1)

$ dbt show --inline 'slect asdlkjfsld;j'
12:32:16  Running with dbt=1.6.0-rc1
12:32:17  Registered adapter: postgres=1.6.0-rc1
12:32:17  Found 7 models, 0 sources, 0 exposures, 0 metrics, 349 macros, 1 group, 0 semantic models
12:32:17
12:32:17  Concurrency: 5 threads (target='postgres')
12:32:17
12:32:17  Encountered an error:
'NoneType' object has no attribute 'print_table'
12:32:17  Traceback (most recent call last):
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 87, in wrapper
    result, success = func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 72, in wrapper
    return func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 172, in wrapper
    return func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 219, in wrapper
    return func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/requires.py", line 259, in wrapper
    return func(*args, **kwargs)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/cli/main.py", line 398, in show
    results = task.run()
  File "/Users/jerco/dev/product/dbt-core/core/dbt/task/runnable.py", line 485, in run
    self.task_end_messages(result.results)
  File "/Users/jerco/dev/product/dbt-core/core/dbt/task/show.py", line 85, in task_end_messages
    table.print_table(output=output, max_rows=None)
AttributeError: 'NoneType' object has no attribute 'print_table'

Context

  • We'll need to backport the fix for this to 1.6.latest, for inclusion in v1.6 RC2/final
  • This behavior affects both dbt show --inline and dbt show --select specific models.
  • This doesn't currently affect the dbt Cloud IDE, which pulls the error message out of the debug-level logs. Still, we should fix this for everyone.
@jtcohen6 jtcohen6 added bug Something isn't working pre-regression Regression not yet in a stable release labels Jul 20, 2023
@github-actions github-actions bot changed the title [v1.6 pre-regression] dbt show swallows database errors [CT-2852] [v1.6 pre-regression] dbt show swallows database errors Jul 20, 2023
@jtcohen6
Copy link
Contributor Author

@aranke I'm going to assign you since you're currently on support rotation, and given your familiarity with the dbt show implementation

@MichelleArk
Copy link
Contributor

Worth noting that this is a regression since 1.6.0rc1. 1.6.0b8 was working as expected:

❯ dbt show --inline 'slect asdlkjfsld;j' --project-dir ~/src/jaffle_shop
19:20:17  Running with dbt=1.6.0-b8
19:20:17  target not specified in profile 'postgres', using 'default'
19:20:17  Registered adapter: postgres=1.7.0-a1
19:20:17  Unable to do partial parsing because of a version mismatch
19:20:18  Found 8 models, 20 tests, 0 snapshots, 0 analyses, 349 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics, 0 groups
19:20:18  
19:20:18  Concurrency: 1 threads (target='default')
19:20:18  
19:20:18  Encountered an error:
Runtime Error
  Database Error in sql_operation inline_query (from remote system.sql)
    syntax error at or near "slect"
    LINE 2: slect asdlkjfsld;j
            ^

@MichelleArk
Copy link
Contributor

Root cause is this return statement within a finally clause: https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/task/runnable.py#L386

From: https://docs.python.org/3/tutorial/errors.html#defining-clean-up-actions

If the finally clause executes a break, continue or return statement, exceptions are not re-raised.

Will put up a fix shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pre-regression Regression not yet in a stable release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants