This is an automated email from the ASF dual-hosted git repository.
jasonliu 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 10cd08dff89 Use contextlib.suppress({exception}) instead of
try-except-pass (#62156)
10cd08dff89 is described below
commit 10cd08dff8916b93f8c3f94bc34265bb7544fde4
Author: Eason09053360 <[email protected]>
AuthorDate: Thu Feb 19 16:41:16 2026 +0800
Use contextlib.suppress({exception}) instead of try-except-pass (#62156)
---
airflow-core/src/airflow/api_fastapi/core_api/security.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/airflow-core/src/airflow/api_fastapi/core_api/security.py
b/airflow-core/src/airflow/api_fastapi/core_api/security.py
index 04fc476dfe5..fc6b398fe21 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/security.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/security.py
@@ -17,6 +17,7 @@
from __future__ import annotations
from collections.abc import Callable, Coroutine
+from contextlib import suppress
from json import JSONDecodeError
from pathlib import Path
from typing import TYPE_CHECKING, Annotated, Any, cast
@@ -303,11 +304,9 @@ def requires_access_backfill(
# Try to retrieve the dag_id from the request body (POST backfill)
if dag_id is None:
- try:
+ # Not a json body, ignore
+ with suppress(JSONDecodeError):
dag_id = (await request.json()).get("dag_id")
- except JSONDecodeError:
- # Not a json body, ignore
- pass
requires_access_dag(method, DagAccessEntity.RUN, dag_id)(
request,