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

   ### Under which category would you file this issue?
   
   Providers
   
   ### Apache Airflow version
   
   main (development)
   
   ### What happened and how to reproduce it?
   
   `HttpHook._url_from_endpoint()` (in 
`providers/http/src/airflow/providers/http/hooks/http.py`) only guards against 
a *missing* slash between `base_url` and `endpoint` — it doesn't guard against 
a *double* one. If a connection's host is configured with a trailing `/` 
(common) and an endpoint is passed with a leading `/` (also common REST 
convention), the resulting URL has `//` in it.
   
   Repro:
   
   ```python
   from airflow.providers.http.hooks.http import HttpHook
   
   hook = HttpHook()
   hook.base_url = "https://api.example.com/v1/";
   hook._base_url_initialized = True
   print(hook.url_from_endpoint("/users"))
   # https://api.example.com/v1//users  <- double slash
   ```
   
   Many API frameworks (Flask, FastAPI, Django) do not normalize `//` in a path 
and will 404 on it, so this produces a silent, confusing failure for anyone 
hitting this combination. Affects both `HttpHook` and `HttpAsyncHook`, since 
both call the shared `_url_from_endpoint()` helper.
   
   ### What you think should happen instead?
   
   Exactly one `/` should separate the base URL and endpoint regardless of 
which side(s) already have a slash. `_url_from_endpoint()` should strip the 
trailing slash from `base_url` and the leading slash from `endpoint` before 
joining, rather than only checking for the missing-slash case.
   
   Happy to open a PR with the fix and a test covering this slash combination — 
will link it here.
   
   ### Operating System
   
   _No response_
   
   ### Deployment
   
   None
   
   ### Apache Airflow Provider(s)
   
   http
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Official Helm Chart version
   
   Not Applicable
   
   ### Kubernetes Version
   
   _No response_
   
   ### Helm Chart configuration
   
   _No response_
   
   ### Docker Image customizations
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] 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