Skip to content

Conversation

@isaiahiruoha
Copy link
Contributor

@isaiahiruoha isaiahiruoha commented Aug 21, 2025

closes: #54753
closes #54665

Problem Description

The Airflow UI Graph View fails to display DAGs containing dynamically mapped operators (created with .expand()). When users try to view such DAGs in the Graph View, the page fails to load and shows a 500 Internal Server Error due to cascading errors in the UI rendering pipeline.

Errors Observed

First Error:

AttributeError: 'MappedOperator' object has no attribute 'topological_sort'
INFO: GET /ui/structure/structure_data?dag_id=integration_test HTTP/1.1" 500 Internal Server Error

Subsequent Error (after fixing the first):

AttributeError: 'MappedOperator' object has no attribute 'downstream_group_ids'. Did you mean: 'downstream_task_ids'?

Both errors occur because MappedOperator instances are incorrectly treated as TaskGroup objects throughout the UI rendering pipeline, causing the system to call TaskGroup-specific methods that don't exist on MappedOperator.

Proposed Solution

Updated both functions to properly recognize MappedOperator as a task-like object rather than a TaskGroup. These changes ensure MappedOperator instances are handled consistently as tasks throughout the entire UI rendering pipeline, preventing both the initial error and subsequent cascading failures.

Testing

Screenshot 2025-08-20 at 4 51 45 PM
  • Verified Graph View now displays correctly for DAGs with mapped operators
  • Tested with example DAGs containing task.expand() operations

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add a pytest to prevent regression of this error?

@isaiahiruoha
Copy link
Contributor Author

Yes for sure, I'll add a unit test early tomorrow

@potiuk potiuk added this to the Airflow 3.0.6 milestone Aug 21, 2025
@potiuk potiuk added the affected_version:3.0 Issues Reported for 3.0 label Aug 21, 2025
@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

cc: @kaxil -> I think that one would be great to get in 3.0.6

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, yes a regression test would be nice. Don't know how and when this got broken. Most probably #53696

@pierrejeambrun
Copy link
Member

cc: @kaxil -> I think that one would be great to get in 3.0.6

Verified, v3-0-test branch is not affect, must be a change targeted for 3.1.0 that broke it.

But we can still preventive cherry pick.

@jscheffl jscheffl modified the milestones: Airflow 3.0.6, Airflow 3.1.0 Aug 21, 2025
@jscheffl jscheffl removed the affected_version:3.0 Issues Reported for 3.0 label Aug 21, 2025
@isaiahiruoha isaiahiruoha force-pushed the iiruoha/fix-missing-graph-view-with-mapped-operators branch from 854de19 to db3a478 Compare August 21, 2025 20:46
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pytest!

@tirkarthi
Copy link
Contributor

This should close #54665 too. Thanks.

Copy link
Contributor

@o-nikolas o-nikolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, love it when there are more lines of test code added then src code 😁

@o-nikolas o-nikolas merged commit e790409 into apache:main Aug 22, 2025
105 checks passed
@o-nikolas o-nikolas deleted the iiruoha/fix-missing-graph-view-with-mapped-operators branch August 22, 2025 17:22
@jscheffl jscheffl added the type:bug-fix Changelog: Bug Fixes label Aug 22, 2025
kaxil added a commit to astronomer/airflow that referenced this pull request Aug 22, 2025
kaxil added a commit to astronomer/airflow that referenced this pull request Aug 23, 2025
…organize tests

Follow-up of the fix in apache#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
kaxil added a commit to astronomer/airflow that referenced this pull request Aug 23, 2025
…organize tests

Follow-up of the fix in apache#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
kaxil added a commit to astronomer/airflow that referenced this pull request Aug 26, 2025
…organize tests

Follow-up of the fix in apache#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
kaxil added a commit that referenced this pull request Aug 26, 2025
…organize tests (#54857)

Follow-up of the fix in #54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
mangal-vairalkar pushed a commit to mangal-vairalkar/airflow that referenced this pull request Aug 30, 2025
mangal-vairalkar pushed a commit to mangal-vairalkar/airflow that referenced this pull request Aug 30, 2025
…organize tests (apache#54857)

Follow-up of the fix in apache#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
nothingmin pushed a commit to nothingmin/airflow that referenced this pull request Sep 2, 2025
…organize tests (apache#54857)

Follow-up of the fix in apache#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing
kosteev pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this pull request Oct 24, 2025
…organize tests (#54857)

Follow-up of the fix in apache/airflow#54756
- Move `task_group_to_dict` and `task_group_to_dict_grid` functions from `task-sdk` to `airflow-core` API services
- Update import paths in `grid.py` and `structure.py` to use new server-side location
- Update deprecation mappings to point to new FastAPI service module locations
- Remove `AbstractOperator` from isinstance checks in server-side functions (now handles only serialized objects)
- Split mixed tests: moved TaskGroup functionality tests to `task-sdk`, keep server function tests in `airflow-core`
- Add comprehensive TaskGroup tests in `task-sdk` covering creation, relationships, decorators, and validation
- Create clear architectural boundary: client-side TaskGroup authoring vs server-side serialized DAG processing

GitOrigin-RevId: c8a0f51f89dc5c75b86c6888154073c08c2a0671
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI does not show Graph View with Dags including Mapped Operators Graph page is empty for dags with dynamic tasks due to server error

6 participants