SameerMesiah97 commented on code in PR #63991:
URL: https://github.com/apache/airflow/pull/63991#discussion_r2971868103
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/tasks.py:
##########
@@ -53,7 +53,15 @@ def get_tasks(
"""Get tasks for DAG."""
dag = get_latest_version_of_dag(dag_bag, dag_id, session)
try:
- tasks = sorted(dag.tasks, key=attrgetter(order_by.lstrip("-")),
reverse=(order_by[0:1] == "-"))
+ attr_name = order_by.lstrip("-")
+ reverse = order_by[0:1] == "-"
+
+ def _sort_key(task):
+ val = attrgetter(attr_name)(task)
+ # Place None values at the end regardless of sort direction
+ return (val is None, val if val is not None else "")
Review Comment:
Is the fallback to empty string necessary? It is unnecessary and introduces
a type assumption. The tuple ordering already guarantees safe handling of None,
so we can avoid this entirely.
--
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]