syhstanley opened a new pull request, #64320:
URL: https://github.com/apache/airflow/pull/64320
closes: #63927
The `GET /api/v2/dags/{dag_id}/tasks` endpoint raises a `TypeError` when
sorting tasks by attributes that contain `None` values (e.g. `start_date`
on unscheduled DAGs), because Python cannot compare `None` with other types.
**Changes:**
- Add a null-safe `sort_key` function inside `get_tasks` that uses tuple
comparison to place `None` values last on ascending sort and first on
descending sort, matching default PostgreSQL `NULLS LAST` / `NULLS FIRST`
behaviour.
- Add a `test_mixed_start_date_dag` test DAG with mixed `None` and non-`None`
`start_date` values.
- Add test cases for:
- Ascending/descending sort with all-`None` values
- Ascending/descending sort with mixed `None`/non-`None` values (verifies
actual ordering)
- Ascending/descending sort by `task_id`
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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]