dbt-labs / dbt-athena

The athena adapter plugin for dbt (https://getdbt.com)
https://dbt-athena.github.io
Apache License 2.0
228 stars 100 forks source link

Is there a way to prevent traceback errors like this? #738

Open moltar opened 1 month ago

moltar commented 1 month ago

Is this your first time submitting an issue in dbt-athena?

Describe your request/question

It hides the actual error message behind a long scrollback.

I snipped the error to a few lines, in reality it's super long.

16:05:03  Finished running  in 0 hours 0 minutes and 0.12 seconds (0.12s).
16:05:03  Encountered an error:
Unable to locate credentials
16:05:03  Traceback (most recent call last):
  File "/.../.env/lib/python3.12/site-packages/dbt/cli/requires.py", line 138, in wrapper
    result, success = func(*args, **kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^

Anything else?

This happens in a few cases, such as when WorkGroup is missing, or query has a typo.

This seems to be related to error handling of the SDK calls?

11:04:48  Registered adapter: athena=1.8.4
Failed to execute query.
Traceback (most recent call last):
  File "/.../.env/lib/python3.12/site-packages/pyathena/common.py", line 575, in _execute
    query_id = retry_api_call(
               ^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/pyathena/util.py", line 84, in retry_api_call
    return retry(func, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/tenacity/__init__.py", line 475, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/tenacity/__init__.py", line 376, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/tenacity/__init__.py", line 398, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.7/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.7/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/.../.env/lib/python3.12/site-packages/tenacity/__init__.py", line 478, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/botocore/client.py", line 569, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../.env/lib/python3.12/site-packages/botocore/client.py", line 1023, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.errorfactory.InvalidRequestException: An error occurred (InvalidRequestException) when calling the StartQueryExecution operation (reached max retries: 0): WorkGroup is not found.
11:04:49    Connection test: [ERROR]

11:04:49  1 check failed:
11:04:49  dbt was unable to connect to the specified database.
The database returned the following error:

  >Runtime Error
  An error occurred (InvalidRequestException) when calling the StartQueryExecution operation (reached max retries: 0): WorkGroup is not found.

Check your database credentials and try again. For more information, visit:
https://docs.getdbt.com/docs/configure-your-profile