Skip to content

Commit

Permalink
Remove unreachable code in _transform_ti_states (apache#44969)
Browse files Browse the repository at this point in the history
Small improvements in airflow/api_fastapi/common/parameters.py:_transform_ti_states
  • Loading branch information
kaxil authored Dec 17, 2024
1 parent 0228832 commit bccd720
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions airflow/api_fastapi/common/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,16 +536,17 @@ def _transform_dag_run_states(states: Iterable[str] | None) -> list[DagRunState

# TI
def _transform_ti_states(states: list[str] | None) -> list[TaskInstanceState | None] | None:
"""Transform a list of state strings into a list of TaskInstanceState enums handling special 'None' cases."""
if not states:
return None

try:
if not states:
return None
return [None if s in ("none", None) else TaskInstanceState(s) for s in states]
except ValueError:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail=f"Invalid value for state. Valid values are {', '.join(TaskInstanceState)}",
)
return states


QueryTIStateFilter = Annotated[
Expand Down

0 comments on commit bccd720

Please sign in to comment.