This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new fd5b551a637 Fix audit log payload for DAG pause/unpause actions 
(#55091)
fd5b551a637 is described below

commit fd5b551a63719b633fd0208a47ac0a087d2114f6
Author: Kaxil Naik <[email protected]>
AuthorDate: Sat Aug 30 12:11:43 2025 +0100

    Fix audit log payload for DAG pause/unpause actions (#55091)
    
    The audit log for DAG pause/unpause operations was incorrectly showing
    the same payload (is_paused: false) for both pause and unpause actions.
    This was caused by faulty logic in the action_logging decorator that
    compared boolean values to the string 'false'.
    
    The fix simplifies the logic to directly use the boolean value from the
    request parameters, ensuring that:
    - Pause actions log 'is_paused': true
    - Unpause actions log 'is_paused': false
    
    Added comprehensive test to verify correct audit log behavior for both
    pause and unpause operations.
    
    Fixes #55074
---
 .../src/airflow/api_fastapi/logging/decorators.py         |  2 +-
 .../unit/api_fastapi/core_api/routes/public/test_dags.py  | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/airflow-core/src/airflow/api_fastapi/logging/decorators.py 
b/airflow-core/src/airflow/api_fastapi/logging/decorators.py
index 2e8169aef97..8ee14acf320 100644
--- a/airflow-core/src/airflow/api_fastapi/logging/decorators.py
+++ b/airflow-core/src/airflow/api_fastapi/logging/decorators.py
@@ -133,7 +133,7 @@ def action_logging(event: str | None = None):
         if has_json_body:
             params.update(masked_body_json)
         if params and "is_paused" in params:
-            extra_fields["is_paused"] = params["is_paused"] == "false"
+            extra_fields["is_paused"] = params["is_paused"]
 
         extra_fields["method"] = request.method
 
diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py
index 99181603cd8..b49e5bb6b3e 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py
@@ -565,6 +565,21 @@ class TestPatchDag(TestDagEndpoint):
         response = unauthorized_test_client.patch(f"/dags/{DAG1_ID}", 
json={"is_paused": True})
         assert response.status_code == 403
 
+    @pytest.mark.parametrize(
+        "is_paused_value",
+        [True, False],
+    )
+    def test_patch_dag_audit_log_payload(self, test_client, is_paused_value, 
session):
+        """Test that audit log payload correctly reflects the is_paused 
value."""
+        response = test_client.patch(f"/dags/{DAG1_ID}", json={"is_paused": 
is_paused_value})
+        assert response.status_code == 200
+
+        # Check that the audit log has the correct is_paused value
+        expected_extra = {"is_paused": is_paused_value, "method": "PATCH"}
+        check_last_log(
+            session, dag_id=DAG1_ID, event="patch_dag", logical_date=None, 
expected_extra=expected_extra
+        )
+
 
 class TestPatchDags(TestDagEndpoint):
     """Unit tests for Patch DAGs."""

Reply via email to