Skip to content

Fix test_get_task_states_with_task_group_id_and_task_id to actually cover its name - #72294

Merged
potiuk merged 1 commit into
apache:mainfrom
ColtenOuO:fix-task-states-group-id-and-task-id-test
Sep 9, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
ColtenOuO:fix-task-states-group-id-and-task-id-test

Conversation

@ColtenOuO

Copy link
Copy Markdown
Contributor

Sumarry

test_get_task_states_with_task_group_id_and_task_id in airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py (TestGetTaskStates) is named to cover the case where GET /execution/task-instances/states is called with both task_group_id and task_ids set — the union-of-both-filters branch in get_task_instance_states (airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py):

if task_group_id:
    group_task_ids = _get_group_task_ids(dag_id, task_group_id, session, dag_bag)
    effective_task_ids = set(task_ids) | group_task_ids if task_ids else group_task_ids
    query = query.where(TI.task_id.in_(effective_task_ids))

The request built by the test only ever set task_group_id in params; task_ids was never passed. That makes the test identical in coverage to test_get_task_states_group_id_basic (which also only exercises task_group_id alone) -- the task_group_id | task_ids union branch was untested despite the test's name claiming otherwise.

Change

  • test_get_task_states_with_task_group_id_and_task_id: added "task_ids": ["task2"] to the request params, alongside task_group_id="group1". task2 is a Dag-level task outside group1 in this test's Dag, and the fixture already assigns it a distinct state (FAILED), so the expected response now asserts both group1.task1 (from the task group) and task2 (from the explicit task_ids filter) appear together in task_states -- actually exercising the union path the test name describes.

…over its name

The test only ever passed task_group_id in the request, never task_ids,
so it exercised the same code path as test_get_task_states_group_id_basic
and left the task_group_id + task_ids union branch in
get_task_instance_states untested despite the test's name.
@boring-cyborg boring-cyborg Bot added the area:API Airflow's REST/HTTP API label Aug 30, 2026
@fat-catTW

Copy link
Copy Markdown
Contributor

Awesome!!

@potiuk
potiuk merged commit 98d8b6e into apache:main Sep 9, 2026
78 checks passed
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…over its name (apache#72294)

The test only ever passed task_group_id in the request, never task_ids,
so it exercised the same code path as test_get_task_states_group_id_basic
and left the task_group_id + task_ids union branch in
get_task_instance_states untested despite the test's name.
regarmukesh3g pushed a commit to regarmukesh3g/airflow that referenced this pull request Sep 27, 2026
…over its name (apache#72294)

The test only ever passed task_group_id in the request, never task_ids,
so it exercised the same code path as test_get_task_states_group_id_basic
and left the task_group_id + task_ids union branch in
get_task_instance_states untested despite the test's name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants