Skip to content

Conversation

@AardJan
Copy link
Contributor

@AardJan AardJan commented Oct 15, 2025

Description

This PR enhances error handling and retry mechanisms in the DBT Hook and its integration with DBT operators.

Changes Made

DBT Hook

  • Implemented comprehensive error handling for both synchronous and asynchronous requests
  • Replaced the run method with run_with_advanced_retry for improved request reliability
  • Added "reraise": True parameter to maintain backward compatibility by raising the original exception after retry threshold is exceeded, rather than a retry-specific error

DBT Operator Integration

  • Updated DBT operators to utilize the enhanced hook functionality through the hook_params parameter

Backward Compatibility

The implementation maintains full backward compatibility with existing code through:

  • Default parameter values that preserve previous behavior
  • Use of reraise to maintain consistent exception handling

Testing

Added comprehensive test coverage for the new retry functionality.

closes: #51801


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@potiuk potiuk merged commit 4ebabc1 into apache:main Oct 15, 2025
92 checks passed
snreddygopu pushed a commit to Teradata/airflow that referenced this pull request Oct 16, 2025
* fix issue when single API error fail entire DbtCloudRunJobOperator task

* fix formatting and refactor get_job_details function

* add hook params to operator and trigger DBT classes

* add docstring, fix function annotation

* add test for retry in hooks and triggers

* fix Hook class param, change method for sync requests

* simplify tests, remove account param

* change test names

* change rerise implementation

* add hook_params for others DBT operators

* change timeout to optional

* add test for timeout param, fix mock warning

* reformat using prek

* change import order, change log request after retry
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 17, 2025
* fix issue when single API error fail entire DbtCloudRunJobOperator task

* fix formatting and refactor get_job_details function

* add hook params to operator and trigger DBT classes

* add docstring, fix function annotation

* add test for retry in hooks and triggers

* fix Hook class param, change method for sync requests

* simplify tests, remove account param

* change test names

* change rerise implementation

* add hook_params for others DBT operators

* change timeout to optional

* add test for timeout param, fix mock warning

* reformat using prek

* change import order, change log request after retry
abdulrahman305 bot pushed a commit to abdulrahman305/airflow that referenced this pull request Oct 19, 2025
* fix issue when single API error fail entire DbtCloudRunJobOperator task

* fix formatting and refactor get_job_details function

* add hook params to operator and trigger DBT classes

* add docstring, fix function annotation

* add test for retry in hooks and triggers

* fix Hook class param, change method for sync requests

* simplify tests, remove account param

* change test names

* change rerise implementation

* add hook_params for others DBT operators

* change timeout to optional

* add test for timeout param, fix mock warning

* reformat using prek

* change import order, change log request after retry
TyrellHaywood pushed a commit to TyrellHaywood/airflow that referenced this pull request Oct 22, 2025
* fix issue when single API error fail entire DbtCloudRunJobOperator task

* fix formatting and refactor get_job_details function

* add hook params to operator and trigger DBT classes

* add docstring, fix function annotation

* add test for retry in hooks and triggers

* fix Hook class param, change method for sync requests

* simplify tests, remove account param

* change test names

* change rerise implementation

* add hook_params for others DBT operators

* change timeout to optional

* add test for timeout param, fix mock warning

* reformat using prek

* change import order, change log request after retry
@2m
Copy link

2m commented Nov 12, 2025

Looking forward to getting this released. We are getting intermittent 502 errors when monitoring dbt jobs.

airflow.exceptions.AirflowException: 502:Bad Gateway

Hopefull this would solve that.

@josh-fell
Copy link
Contributor

Looking forward to getting this released. We are getting intermittent 502 errors when monitoring dbt jobs.

airflow.exceptions.AirflowException: 502:Bad Gateway

Hopefull this would solve that.

This was released a couple week ago as part of v4.4.4 of the provider. Are you seeing this issue on that version still?

@2m
Copy link

2m commented Nov 12, 2025

Ahh, sorry. I tried looking at the latest tag for the provider and then I did not see this change. But I checked again, and now all is clear. User error. :)

I will try out updating our provider.

We are using quite an outdated airflow (2.9.1) currently. Do you know if latest dbt provider is going to be compatible with that? Is there some resource I could check which airflow versions are compatible with the latest dbt provider?

@josh-fell
Copy link
Contributor

It is not; only supported on Airflow 2.10+. In the provider's changelog I linked to, and on PyPI, you can find the minimum Airflow version requirements that is supported in each provider version.

If it helps for context, we have documentation on why/when the minimum Airflow version is bumped for providers too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry on server side failures when checking status of DBT cloud jobs

4 participants