kaxil commented on code in PR #70990:
URL: https://github.com/apache/airflow/pull/70990#discussion_r3737340030
##########
airflow-core/tests/unit/dag_processing/test_processor.py:
##########
@@ -814,6 +814,41 @@ def test_execute_callbacks_locks_bundle_version(self):
mock_lock.return_value.__exit__.assert_called_once()
mock_execute.assert_called_once_with(dagbag, callbacks[0], log)
+ def test_execute_callbacks_continues_after_failed_request(self,
spy_agency):
+ """A request for a removed Dag must not abort the remaining requests
in the batch."""
+ called = False
+
+ def on_failure(context):
+ nonlocal called
+ called = True
+
+ dag = DAG(dag_id="a", on_failure_callback=on_failure)
+
+ def fake_collect_dags(self, *args, **kwargs):
+ self.dags[dag.dag_id] = dag
+
+ spy_agency.spy_on(DagBag.collect_dags, call_fake=fake_collect_dags,
owner=DagBag)
+ dagbag = DagBag()
+ dagbag.collect_dags()
+
+ def make_request(dag_id):
+ return DagCallbackRequest(
+ filepath="test.py",
+ dag_id=dag_id,
+ run_id="test_run",
+ bundle_name="testing",
+ bundle_version=None,
+ is_failure_callback=True,
+ msg="Message",
+ )
+
+ log = MagicMock(spec=FilteringBoundLogger)
+ _execute_callbacks(dagbag, [make_request("removed_dag"),
make_request("a")], log)
+
+ assert called is True
+ log.exception.assert_called_once()
+ assert log.exception.call_args.kwargs["dag_id"] == "removed_dag"
Review Comment:
Optional: this pins the log-context bind but not the exclusion.
`exclude={"context_from_server"}` is the only thing keeping `DagRun.conf` out
of dag-processor logs now that this payload is logged at ERROR, and dropping it
is detectable here (on pydantic 2.13.4 the field serializes as
`"context_from_server":null` even when it is `None`), so this assertion fails
if the exclusion is ever removed:
```python
assert "context_from_server" not in log.exception.call_args.kwargs["request"]
```
--
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]