GitHub user artur282 added a comment to the discussion: HttpHook and
HttpAsyncHook disagree on allowed HTTP methods (surfaced by QUERY)
Thanks for the write-up — I read the provider source to check the asymmetry,
and it is exactly as you describe. Two things I can add.
**1. Option 1 is verified to work with aiohttp.** I ran a local aiohttp server
and client (`aiohttp` 3.x):
```text
request(QUERY) -> 200 metodo recibido: QUERY
```
`session.request(method, url, **kwargs)` sends an arbitrary method token,
including ones with no per-verb helper, so a generic dispatch is possible
without waiting for a `session.query()` helper.
**2. The method whitelist is not the only closed set to fix.** The body/payload
mapping has the same shape, in `AsyncHttpSession._request()`
(`providers/http/src/airflow/providers/http/hooks/http.py`):
```python
params=data if method == "GET" else None
data=data if method in {"POST", "PUT", "PATCH"} else None
```
so with `method="QUERY"` the body would still be dropped even after the
dispatch is generalised, and `DELETE` with a body stays impossible. If the
direction is option 1, the condition should follow what the sync branch already
does (`GET` → `params`, everything else → `data`) rather than a hand-maintained
set.
For completeness, the third spot you mention is real and already consistent
with the divergence: `IDEMPOTENT_METHODS = frozenset({"GET", "HEAD", "OPTIONS",
"PUT", "DELETE", "TRACE"})` in
`providers/http/src/airflow/providers/http/operators/http.py:38`, used by
`_warn_if_deferrable_non_idempotent_method()`.
**On the direction:** option 1 also removes the validation that currently makes
a typo'd method fail loudly (`method="GETT"` today raises instead of hitting
the network), which is a real, if small, safety property. A middle ground that
keeps both: validate the token shape (`method.isupper()` / RFC 9110 token
chars) and then dispatch generically — that way the sync and async hooks accept
the same set *and* a malformed method is still rejected before any request is
issued. `IDEMPOTENT_METHODS` then needs `QUERY` only if you want the
retry/deferrable warning to treat it as safe (per the draft, it is safe and
idempotent).
GitHub link:
https://github.com/apache/airflow/discussions/72619#discussioncomment-18406003
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]