aryansk opened a new pull request, #71660:
URL: https://github.com/apache/airflow/pull/71660

   closes #71658
   
   ### What is changing and why
   
   `HttpHook._url_from_endpoint()` (used by both `HttpHook` and 
`HttpAsyncHook`) only guarded against a *missing* slash between `base_url` and 
`endpoint` — it did not guard against a *double* one. When a connection host is 
configured with a trailing `/` (common) and an endpoint is passed with a 
leading `/` (also common REST convention), the resulting URL contained `//`:
   
   ```python
   hook.base_url = "https://api.example.com/v1/";
   hook.url_from_endpoint("/users")
   # before: https://api.example.com/v1//users
   # after:  https://api.example.com/v1/users
   ```
   
   Many API frameworks (Flask, FastAPI, Django) do not normalize `//` in a path 
and return 404, so this produced a silent, confusing failure.
   
   The fix joins `base_url` and `endpoint` with exactly one `/` in all cases, 
preserving the existing behavior for every other input combination (including 
scheme-only base URLs such as `http://`, and endpoint-only requests).
   
   ### Tests
   
   - Added parametrized regression cases to `test_url_from_endpoint` covering 
trailing-slash, leading-slash, and both.
   - `providers/http/tests/unit/http/hooks/test_http.py`: 60 passed, 1 
pre-existing environment error (verified identical on `main`).
   - `ruff check` and `ruff format --check` clean on both changed files.


-- 
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