jebakishore509-sys opened a new pull request, #76358:
URL: https://github.com/apache/airflow/pull/76358
Pass `response_error_codes_allowlist` from `HttpSensor` to
`HttpSensorTrigger` in deferrable mode, serialize the parameter, and retry on
allowlisted error codes while re-raising non-allowlisted errors.
### Problem & Root Cause
In `HttpSensor`, `response_error_codes_allowlist` allows users to specify
HTTP error codes (e.g. `("404", "503")`) that should be ignored while poking
until the endpoint becomes available. Non-allowlisted error codes fail
immediately by raising `AirflowException`.
However, when `deferrable=True` is set:
1. `HttpSensor.execute()` did not forward `response_error_codes_allowlist`
when creating `HttpSensorTrigger`.
2. `HttpSensorTrigger` did not accept or serialize
`response_error_codes_allowlist`.
3. In `HttpSensorTrigger.run()`, the trigger caught `AirflowException` and
only checked `str(exc).startswith("404")`. Crucially, if the exception was any
other status code, it did not re-raise or handle it, causing an unyielding loop
rather than failing the task.
### Solution
1. In `HttpSensor.execute()`: pass
`response_error_codes_allowlist=self.response_error_codes_allowlist` to
`HttpSensorTrigger`.
2. In `HttpSensorTrigger.__init__()`: accept
`response_error_codes_allowlist` (defaulting to `("404",)`) and normalize it to
a tuple for `str.startswith()`.
3. In `HttpSensorTrigger.serialize()`: serialize
`response_error_codes_allowlist`.
4. In `HttpSensorTrigger.run()`:
- Check `if str(exc).startswith(self.response_error_codes_allowlist)`,
sleep for `poke_interval` and `continue`.
- Re-raise unhandled `AirflowException` immediately so non-allowlisted
errors fail the task as expected.
5. Added unit tests for serialization with default and custom allowlists,
trigger retries on allowlisted errors, trigger re-raising on unhandled errors,
and `HttpSensor.execute()` deferral parameter passing.
closes: #69903
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (Antigravity)
Generated-by: Antigravity following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
--
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]