-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow Provider(s)
dbt-cloud
Versions of Apache Airflow Providers
While testing the DBT connection through Airflow → Connections, we found that the request is returning a 400 response code.
{
"message": "400:Bad Request",
"status": false
}
dbt provider version
apache-airflow-providers-dbt-cloud==3.11.2
Apache Airflow version
2.10.4
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Docker-Compose
Deployment details
Please find attached the Docker Compose file and the requirements I used
.env
AIRFLOW_UID=50000
_AIRFLOW_WWW_USER_USERNAME=airflow
_AIRFLOW_WWW_USER_PASSWORD=airflow
_PIP_ADDITIONAL_REQUIREMENTS=apache-airflow-providers-dbt-cloud==3.11.2
What happened
When creating the DBT connection in Airflow > Connection and clicking the Test button, it displays a 400: Bad Request error even though the credentials are valid.
While reviewing the test_connection method in DbtCloudHook, I noticed that it calls self._run_and_get_response() without passing any parameters. https://github.com/apache/airflow/blob/providers-dbt-cloud/3.11.2/providers/src/airflow/providers/dbt/cloud/hooks/dbt.py#L718C18-L718C39
def test_connection(self) -> tuple[bool, str]:
"""Test dbt Cloud connection."""
try:
self._run_and_get_response() # <= Here it's calling without endpoint parameters
return True, "Successfully connected to dbt Cloud."
except Exception as e:
return False, str(e)
As a result, full_endpoint becomes None, causing the dbt API request to be sent with only the host URL and no valid endpoint, which leads to the request failing
curl --location 'https://XXXXX.us1.dbt.com/' \
--header 'Authorization: Token XXXXXX' \
--header 'Content-Type: application/json'
What you think should happen instead
When we add the default endpoint, we receive a 200 response code. So adding the endpoint parameter to _run_and_get_response in test_connection will fix the isssue
curl
curl --location 'https://XX.us1.dbt.com/api/v2/accounts/' \
--header 'Authorization: Token XXX' \
--header 'Content-Type: application/json'
How to reproduce
add the apache-airflow-providers-dbt-cloud==3.11.2 in your AF2 requirements.txt, then try creating a connection and clicking the Test button before saving to reproduce the issue.
Anything else
No response
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct