Shushankranjan opened a new pull request, #68539:
URL: https://github.com/apache/airflow/pull/68539
When the Execution API rejects a variable write (any non-2xx response —
e.g. a 403 authorization denial or a server error), `Variable.set()` and
`Variable.delete()` were catching `AirflowRuntimeError` and only logging
it. The task still finished as **success** and the variable was left
unchanged.
This is inconsistent with `Variable.get()`, which already raises on error
(and since #66575 even refuses secrets-backend fallback on a 401/403).
Reads fail loudly on denial; writes silently succeeded.
### Changes
- **`Variable.set()`**: Remove the `try/except AirflowRuntimeError` block
that swallowed the error. Any API rejection now propagates and fails the
task.
- **`Variable.delete()`**: Same fix.
- Remove the now-unused `logging` import and `log` variable from
`variable.py`.
- Add `test_var_set_raises_on_error` and `test_var_delete_raises_on_error`
to cover the error propagation path.
### Root cause
```python
# Before (broken)
try:
_set_variable(...)
except AirflowRuntimeError as e:
log.exception(e) # swallowed — task reports success
# After (fixed)
_set_variable(...) # AirflowRuntimeError propagates — task fails
```
closes: #68537
Related: #66575 (fixed the analogous read / secrets-backend path)
--
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]