gunjisairevanth opened a new issue, #58941:
URL: https://github.com/apache/airflow/issues/58941

   ### 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
   }
   
   ```
   
   <img width="1721" height="456" alt="Image" 
src="https://github.com/user-attachments/assets/9ba77c38-11ec-4e7f-aec0-2052e34c61d1";
 />
   
   **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
   
   
[docker-compose.yml](https://github.com/user-attachments/files/23882337/docker-compose.yml)
   
   
[requirements.txt](https://github.com/user-attachments/files/23882340/requirements.txt)
   
   .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.
   
   <img width="1716" height="600" alt="Image" 
src="https://github.com/user-attachments/assets/1012fd64-2d9d-4b1f-acad-48516919d645";
 />
   
   
   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](url)
   ```
       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](https://github.com/apache/airflow/blob/providers-dbt-cloud/4.6.0/providers/dbt/cloud/src/airflow/providers/dbt/cloud/hooks/dbt.py#L412),
 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'
   ```
   
   <img width="897" height="270" alt="Image" 
src="https://github.com/user-attachments/assets/216782c6-5229-4921-881c-47a8dd6c5b30";
 />
   
   
   ### 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'
   ```
   
   <img width="895" height="587" alt="Image" 
src="https://github.com/user-attachments/assets/6fb3645b-45f9-46c0-bc9a-fdfe3ea0fa5a";
 />
   
   ### 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
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to