Fix GET tasks endpoint crash when sorting by attributes with None values#64320
Closed
syhstanley wants to merge 2 commits into
Closed
Fix GET tasks endpoint crash when sorting by attributes with None values#64320syhstanley wants to merge 2 commits into
syhstanley wants to merge 2 commits into
Conversation
The GET /api/v2/dags/{dag_id}/tasks endpoint raises a TypeError when
sorting by attributes like start_date that contain None values
(e.g. unscheduled DAGs). Add a null-safe sort key inside get_tasks
that places None values last on ascending and first on descending,
matching default PostgreSQL behaviour.
Closes: apache#63927
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pierrejeambrun
left a comment
Member
There was a problem hiding this comment.
Closing in favor of #64384
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: #63927
The
GET /api/v2/dags/{dag_id}/tasksendpoint raises aTypeErrorwhensorting tasks by attributes that contain
Nonevalues (e.g.start_dateon unscheduled DAGs), because Python cannot compare
Nonewith other types.Changes:
sort_keyfunction insideget_tasksthat uses tuplecomparison to place
Nonevalues last on ascending sort and first ondescending sort, matching default PostgreSQL
NULLS LAST/NULLS FIRSTbehaviour.
test_mixed_start_date_dagtest DAG with mixed None and non-Nonestart_datevalues.task_idWas generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines