This is an automated email from the ASF dual-hosted git repository.
pierrejeambrun 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 46a433d5087 Handle non-dictionary json payload during logging to avoid
internal server error. (#62355)
46a433d5087 is described below
commit 46a433d5087b48e6b124f7f30fdeeb63f7944a5a
Author: Karthikeyan Singaravelan <[email protected]>
AuthorDate: Mon Feb 23 21:52:39 2026 +0530
Handle non-dictionary json payload during logging to avoid internal server
error. (#62355)
---
.../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 93e96bef385..a4734bb3e41 100644
--- a/airflow-core/src/airflow/api_fastapi/logging/decorators.py
+++ b/airflow-core/src/airflow/api_fastapi/logging/decorators.py
@@ -92,16 +92,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 6eba2cd7e43..e00d075f2a7 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
@@ -1733,11 +1733,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