You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "bnspopi (via GitHub)" <gi...@apache.org> on 2026/10/13 10:23:21 UTC
[PR] Fix double slash in HTTP hook URLs [airflow]
bnspopi opened a new pull request, #74639:
URL: https://github.com/apache/airflow/pull/74639
`_url_from_endpoint()` only guarded the missing-slash case. A connection host with a trailing `/` and an endpoint with a leading `/` are both ordinary on their own, and together they produce a URL with an empty path segment:
```python
hook.base_url = "https://api.example.com/v1/"
hook.url_from_endpoint("/users")
# https://api.example.com/v1//users
```
Flask, FastAPI and Django do not normalise `//` in a path, so the request 404s and nothing in the error points at the slash. Both `HttpHook` and `HttpAsyncHook` go through this helper, so both are affected.
The join now strips trailing slashes from the base URL and leading slashes from the endpoint, leaving exactly one separator. That cannot be unconditional: a connection without a host leaves the base URL as `"<scheme>://"`, where the trailing slashes are the authority separator rather than a path boundary, so stripping them would turn the first path segment into the host. That case keeps the current behaviour, which `TestHttpAsyncHook.test_build_request_url_from_endpoint_param` already pins through `http_empty_conn`.
Tests: `test_url_from_endpoint` gains the slash combinations (base-only, endpoint-only, one side, both sides, repeated slashes) and the scheme-only base URL.
An earlier PR for this issue, #71665, was closed as stale without review. It removed one slash from each side unconditionally, which turns a hostless `"http://"` base URL into `"http:/"` — the case this PR special-cases instead.
I could not run the provider test suite on this machine, so the first full run will be CI here; happy to follow up on anything it flags.
closes: #71658
related: #71665
---
##### Was generative
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix double slash in HTTP hook URLs [airflow]
Posted by "yuseok89 (via GitHub)" <gi...@apache.org>.
yuseok89 commented on code in PR #74639:
URL: https://github.com/apache/airflow/pull/74639#discussion_r4306186616
##########
providers/http/tests/unit/http/hooks/test_http.py:
##########
@@ -614,9 +614,22 @@ def test_keep_alive_disabled(self):
[
pytest.param("https://example.org", "/v1/test", "https://example.org/v1/test", id="both-set"),
pytest.param("", "http://foo/bar/v1/test", "http://foo/bar/v1/test", id="only-endpoint"),
+ pytest.param("https://example.org/v1", "test", "https://example.org/v1/test", id="no-slash"),
+ pytest.param("https://example.org/v1/", "test", "https://example.org/v1/test", id="base-slash"),
+ pytest.param(
+ "https://example.org/v1/", "/test", "https://example.org/v1/test", id="slash-on-both-sides"
+ ),
+ pytest.param(
+ "https://example.org/v1//", "//test", "https://example.org/v1/test", id="repeated-slashes"
+ ),
+ pytest.param("https://example.org/v1/", "", "https://example.org/v1/", id="only-base"),
+ pytest.param("https://example.org/v1/", None, "https://example.org/v1/", id="endpoint-none"),
+ # A connection without a host leaves the authority empty, so the base url is the
+ # scheme separator itself and must not be mistaken for a trailing path slash.
+ pytest.param("https://", "/v1/test", "https:///v1/test", id="scheme-only-base"),
Review Comment:
Is preserving `https:///v1/test` intentional even though it has no host and is rejected by Requests?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org