Skip to content

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented May 16, 2025

In some rare cases, the DAG parse subprocess (DagFileProcessorProcess) could raise a PydanticUserError related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by TypeAdapter[ToDagProcessor] being instantiated before DagFileParseRequest was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (ToDagProcessor, ToManager) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes #50530


^ 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.

…efinitions

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes apache#50530
@kaxil kaxil added this to the Airflow 3.0.2 milestone May 16, 2025
@kaxil kaxil changed the title Fix Pydantic ForwardRef error by reordering discriminated union d… Fix ForwardRef error in DAG parse subprocess May 16, 2025
@aa-matthias aa-matthias mentioned this pull request May 16, 2025
2 tasks
@jedcunningham jedcunningham added type:bug-fix Changelog: Bug Fixes backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch labels May 16, 2025
@jedcunningham jedcunningham merged commit 672ec99 into apache:main May 16, 2025
54 checks passed
@jedcunningham jedcunningham deleted the remove-fwd-ref branch May 16, 2025 13:34
github-actions bot pushed a commit that referenced this pull request May 16, 2025
…ated union definitions (#50688)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes #50530
(cherry picked from commit 672ec99)

Co-authored-by: Kaxil Naik <[email protected]>
Copy link

Backport successfully created: v3-0-test

Status Branch Result
v3-0-test PR Link

github-actions bot pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request May 16, 2025
…ated union definitions (apache#50688)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes apache#50530
(cherry picked from commit 672ec99)

Co-authored-by: Kaxil Naik <[email protected]>
kaxil added a commit that referenced this pull request May 19, 2025
…ated union definitions (#50688)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes #50530
(cherry picked from commit 672ec99)

Co-authored-by: Kaxil Naik <[email protected]>
kaxil added a commit that referenced this pull request May 20, 2025
…ated union definitions (#50688) (#50691)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes #50530
(cherry picked from commit 672ec99)

Co-authored-by: Kaxil Naik <[email protected]>
kaxil added a commit that referenced this pull request Jun 3, 2025
…ated union definitions (#50688) (#50691)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes #50530
(cherry picked from commit 672ec99)

Co-authored-by: Kaxil Naik <[email protected]>
sanederchik pushed a commit to sanederchik/airflow that referenced this pull request Jun 7, 2025
…efinitions (apache#50688)

In some rare cases, the DAG parse subprocess (`DagFileProcessorProcess`) could raise a `PydanticUserError` related to unresolved ForwardRefs in the discriminated union ToDagProcessor.

This was caused by `TypeAdapter[ToDagProcessor]` being instantiated before `DagFileParseRequest` was defined. While this is not always reproducible, it can happen in forked subprocesses depending on import order.

This change moves the union definitions (`ToDagProcessor`, `ToManager`) after the relevant Pydantic models are declared, ensuring all references are fully resolved at definition time.

closes apache#50530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:DAG-processing backport-to-v3-0-test Mark PR with this label to backport to v3-0-test branch type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dag Processor Error
2 participants