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

pierrejeambrun pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 96222635cdf [v3-1-test] Handle non-dictionary json payload during 
logging to avoid internal server error. (#62355) (#62367)
96222635cdf is described below

commit 96222635cdf404d19127513e5b3dd72581b7acb3
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Feb 24 14:56:05 2026 +0100

    [v3-1-test] Handle non-dictionary json payload during logging to avoid 
internal server error. (#62355) (#62367)
    
    (cherry picked from commit 46a433d5087b48e6b124f7f30fdeeb63f7944a5a)
    
    Co-authored-by: Karthikeyan Singaravelan <[email protected]>
---
 .../src/airflow/api_fastapi/logging/decorators.py      | 12 ++++++------
 .../api_fastapi/core_api/routes/public/test_dag_run.py | 18 ++++++++++++++++--
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/airflow-core/src/airflow/api_fastapi/logging/decorators.py 
b/airflow-core/src/airflow/api_fastapi/logging/decorators.py
index d5a073f3044..6503d2da6cc 100644
--- a/airflow-core/src/airflow/api_fastapi/logging/decorators.py
+++ b/airflow-core/src/airflow/api_fastapi/logging/decorators.py
@@ -91,16 +91,16 @@ def action_logging(event: str | None = None):
             user_display = user.get_name()
 
         has_json_body = "application/json" in 
request.headers.get("content-type", "") and await request.body()
+        request_body = {}
+        masked_body_json = {}
 
         if has_json_body:
             request_body = await request.json()
-            masked_body_json = {k: secrets_masker.redact(v, k) for k, v in 
request_body.items()}
-        else:
-            request_body = {}
-            masked_body_json = {}
+            if isinstance(request_body, dict):
+                masked_body_json = {k: secrets_masker.redact(v, k) for k, v in 
request_body.items()}
 
-        if event_name in skip_dry_run_events and request_body.get("dry_run", 
True):
-            return
+                if event_name in skip_dry_run_events and 
request_body.get("dry_run", True):
+                    return
 
         fields_skip_logging = {
             "csrf_token",
diff --git 
a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py 
b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py
index 63088ba4f39..28c019b7f74 100644
--- a/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py
+++ b/airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_run.py
@@ -1656,11 +1656,25 @@ class TestTriggerDagRun:
                     ]
                 },
             ),
+            (
+                [],
+                {
+                    "detail": [
+                        {
+                            "type": "model_attributes_type",
+                            "loc": ["body"],
+                            "msg": "Input should be a valid dictionary or 
object to extract fields from",
+                            "input": [],
+                        }
+                    ]
+                },
+            ),
         ],
     )
     def test_invalid_data(self, test_client, post_body, expected_detail):
-        now = timezone.utcnow().isoformat()
-        post_body["logical_date"] = now
+        if isinstance(post_body, dict):
+            now = timezone.utcnow().isoformat()
+            post_body["logical_date"] = now
         response = test_client.post(f"/dags/{DAG1_ID}/dagRuns", json=post_body)
         assert response.status_code == 422
         assert response.json() == expected_detail

Reply via email to