Skip to content

Conversation

@ashb
Copy link
Member

@ashb ashb commented Aug 21, 2025

Fixes #54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because Iterable is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.


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

Fixes #54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because `Iterable` is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.
@VladaZakharova
Copy link
Contributor

Hi
thank you for the fix
Did you check this on different types? can you please add unit tests for that?

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Damn. Pydantic runtime type usage has side effects - that change looks lile it changes nothing....

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

Hi thank you for the fix Did you check this on different types? can you please add unit tests for that?

@ashb wrote:

Yes, this should absolutely have unit tests to go with the fix, but a fix is better than nothing, and I'm about to leave on a camping holiday.

I guess we should add unit tests as follow-up without breaking @ashb's plans.

@ashb
Copy link
Member Author

ashb commented Aug 21, 2025

Anyone hitting this on 3.0.5 andwho doesn't want to rollback to 3.0.4: a work around for now is to manually apply this patch to your Airflow.

If you are using docker to deploy your airflow then something like this should help hopefully:

USER root

RUN apt update && apt install -y patch patchutils

RUN set -ex; \
    cd /usr/local/lib/python3.12/site-packages/airflow; \
    curl -L https://patch-diff.githubusercontent.com/raw/apache/airflow/pull/54769.patch \
    | filterdiff -p1 -i 'task-sdk/src/airflow/*' | patch -p4 -u --verbose

USER airflow

The path to site-packages and the user to switch back to at the end would need adapting to your specific Dockerfile

@ashb
Copy link
Member Author

ashb commented Aug 21, 2025

Did you check this on different types? can you please add unit tests for that?

I manually tested it with this:

First set the conneciton:

export AIRFLOW_CONN_TEST='{"conn_type": "google_cloud_default", "extra": {"key_path": "/files/airflow-breeze-config/keys2/keys.json", "scope": "https://www.googleapis.com/auth/cloud-platform", "project": "project_id", "num_retries": 6}}

Than I ran this DAG:

@task
def my_function() -> None:
    conn = Connection.get("test")

    print(f"{conn.conn_id=} {conn.password=} {conn.extra_dejson=} {conn=}")

with DAG("test_dag") as dag:
    my_function()

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

I manually tested it with this:

I will take it from now on @ashb -> thanks for the repro scenarios

Copy link
Contributor

@amoghrajesh amoghrajesh left a comment

Choose a reason for hiding this comment

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

Damn!

@amoghrajesh
Copy link
Contributor

@ashb mypy will need a fix:

  task-sdk/src/airflow/sdk/execution_time/secrets_masker.py:127: error: Argument "value" to "MaskSecret" has incompatible type "str | Iterable[Any]"; expected "JsonValue"  [arg-type]
              comms.send(MaskSecret(value=secret, name=name))
                                          ^~~~~~
  task-sdk/src/airflow/sdk/execution_time/supervisor.py:1351: error: Argument 1 to "mask_secret" has incompatible type "list[JsonValue] | dict[str, JsonValue] | str | int | float | None"; expected
  "str | dict[Any, Any] | Iterable[Any]"  [arg-type]
                  mask_secret(msg.value, msg.name)
                              ^~~~~~~~~
  Found 2 errors in 2 files (checked 126 source files)

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

^~~~~~
task-sdk/src/airflow/sdk/execution_time/supervisor.py:1351: error: Argument 1 to "mask_secret" has incompatible type "list[JsonValue] | dict[str, JsonValue] | str | int | float | None"; expected
"str | dict[Any, Any] | Iterable[Any]" [arg-type]
mask_secret(msg.value, msg.name)
^~~~~~~~~
Found 2 errors in 2 files (checked 126 source files)

I'll copy the PR and fix it -> and I will ask others to help :) .. @ashb will not be available to fix it @amoghrajesh

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

Ah... It's in `apache/airflow" so we can push to it directly

@VladaZakharova
Copy link
Contributor

Originally, there was also the problem with triggerers with the following errors:

dataplex_data_profile: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataplex_data_quality: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_batch_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_spark_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
example_gcp_transfer: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_transfer_gcs_to_gcs: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_gcp_transfer_aws: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)

do you think we can also fix the types for masks to solve this problem too?

@gopidesupavan
Copy link
Member

oh geeee...

@amoghrajesh
Copy link
Contributor

@potiuk you can push directly to the PR. No need to copy it.

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

@potiuk you can push directly to the PR. No need to copy it.

Yep. Will do

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

We can work together @amoghrajesh -> and add more related fixes possibly (looking at the last comment from @VladaZakharova ).

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

Let's just push fixups without -f : to not override each-others's changes.

@amoghrajesh
Copy link
Contributor

amoghrajesh commented Aug 21, 2025

Dropped you a message on slack, looking into mypy failures

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

pushed mypy fix :)

@VladaZakharova
Copy link
Contributor

VladaZakharova commented Aug 21, 2025

We can work together @amoghrajesh -> and add more related fixes possibly (looking at the last comment from @VladaZakharova ).

will be happy to discuss and help, because now it looks like if we extend this logic with types, maybe we can also add support of Enums and other types that are not standard. Because the current logic only supports limited number of objects. The problem with triggers was the first one, and now with this masking it's just making clear with connections that it doesn't work as expected

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

will be happy to discuss and help, because now it looks like if we extend this logic with types, maybe we can also add support of Enums and other types that are not standard. Because the current logic only supports limited number of objects. The problem with triggers was the first one, and now with this masking it's just making clear with connections that it doesn't work as expected

Let's focus on getting unit testing for that one first - and then we can see what we can do with Enums - this one is pretty burning :).

@VladaZakharova
Copy link
Contributor

will be happy to discuss and help, because now it looks like if we extend this logic with types, maybe we can also add support of Enums and other types that are not standard. Because the current logic only supports limited number of objects. The problem with triggers was the first one, and now with this masking it's just making clear with connections that it doesn't work as expected

Let's focus on getting unit testing for that one first - and then we can see what we can do with Enums - this one is pretty burning :).

agree :)

@amoghrajesh
Copy link
Contributor

Agreed too. Let's fix the error at hand first and we can always follow up for the non breaking / burning things...

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

fixup with tests is here

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

Also @VladaZakharova -> those seem to be unrelated, it seems that simply we would have to add custom serializer to pydantic to handle those enums and classes that are being serialized. How do you arrive at those errors?

dataplex_data_profile: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataplex_data_quality: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_batch_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_spark_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
example_gcp_transfer: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_transfer_gcs_to_gcs: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_gcp_transfer_aws: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)

@amoghrajesh
Copy link
Contributor

Yeah I do not think it is directly linked to this PR

@kaxil
Copy link
Member

kaxil commented Aug 21, 2025

Also @VladaZakharova -> those seem to be unrelated, it seems that simply we would have to add custom serializer to pydantic to handle those enums and classes that are being serialized. How do you arrive at those errors?

dataplex_data_profile: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataplex_data_quality: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_batch_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
dataproc_spark_deferrable: kills the triggerer (NotImplementedError: Objects of type <enum 'State'> are not supported)
example_gcp_transfer: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_transfer_gcs_to_gcs: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)
example_gcp_transfer_aws: kill the triggerer (NotImplementedError: Objects of type <class 'google.cloud.sotrage_transfer_v1.types.transfer_types.TransferOperation'> are not supported)

Yeah unrelated

Copy link
Contributor

@amoghrajesh amoghrajesh left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@potiuk potiuk added the backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch label Aug 21, 2025
@kaxil
Copy link
Member

kaxil commented Aug 21, 2025

Compat test change: #54776

@potiuk
Copy link
Member

potiuk commented Aug 21, 2025

Merging it 3.0.5 fails clearly because of yanking :) and #54766 is already on the way.

@potiuk potiuk merged commit 5aec867 into main Aug 21, 2025
74 of 75 checks passed
@potiuk potiuk deleted the fix-extra-connection-masking branch August 21, 2025 12:40
github-actions bot pushed a commit that referenced this pull request Aug 21, 2025
…ng an error (#54769)

* Ensure that Connection extra can get masked without causing an error

Fixes #54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because `Iterable` is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.

* fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! fixup! Ensure that Connection extra can get masked without causing an error

---------
(cherry picked from commit 5aec867)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
@github-actions
Copy link

Backport successfully created: v3-0-test

Status Branch Result
v3-0-test PR Link

kaxil pushed a commit that referenced this pull request Aug 21, 2025
…ng an error (#54769) (#54780)

* Ensure that Connection extra can get masked without causing an error

Fixes #54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because `Iterable` is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.

* fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! fixup! Ensure that Connection extra can get masked without causing an error

---------
(cherry picked from commit 5aec867)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
kaxil pushed a commit that referenced this pull request Aug 22, 2025
…ng an error (#54769) (#54780)

* Ensure that Connection extra can get masked without causing an error

Fixes #54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because `Iterable` is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.

* fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! fixup! Ensure that Connection extra can get masked without causing an error

---------
(cherry picked from commit 5aec867)

Co-authored-by: Ash Berlin-Taylor <ash@apache.org>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
mangal-vairalkar pushed a commit to mangal-vairalkar/airflow that referenced this pull request Aug 30, 2025
…pache#54769)

* Ensure that Connection extra can get masked without causing an error

Fixes apache#54768

This was caused by pydantic#9541 and improper testing on my part. Sorry
folks. Thsi happens because `Iterable` is too open-ended a type

Yes, this should absolutely have unit tests to go with the fix, but a fix is
better than nothing, and I'm about to leave on a camping holiday.

* fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! Ensure that Connection extra can get masked without causing an error

* fixup! fixup! fixup! Ensure that Connection extra can get masked without causing an error

---------

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:task-sdk backport-to-v3-1-test Mark PR with this label to backport to v3-1-test branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use of conn.extra_dejson in Airflow 3.0.5 fails with NotImplementedError error

9 participants