Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect against accidental misuse of XCom.get_value() #22244

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Mar 14, 2022

The XCom.get_value has been added in 2.3.0 and while there are
cases it should be used in the providers when task are mapped,
in order to keep compatibility with earlier versions of Airlfow,
the XCom.get_value() should only be used when ti_key is not None.

We check for the construct used in community providers automatically
and also add a documentation for users who would like to use
dynamic task mapping featuers in their own providers.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, 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 UPDATING.md.

@boring-cyborg boring-cyborg bot added area:dev-tools area:providers kind:documentation provider:amazon-aws AWS/Amazon - related issues provider:microsoft-azure Azure-related issues provider:google Google (including GCP) related issues labels Mar 14, 2022
@potiuk potiuk force-pushed the add-protection-against-incompatible-xcom-getvalue-usage branch from 138827d to b9b1b11 Compare March 14, 2022 14:45
@potiuk
Copy link
Member Author

potiuk commented Mar 14, 2022

Updated it so the error looks a bit nicer:

image

@potiuk potiuk force-pushed the add-protection-against-incompatible-xcom-getvalue-usage branch from b9b1b11 to 6161beb Compare March 14, 2022 14:46
@potiuk
Copy link
Member Author

potiuk commented Mar 14, 2022

I'd love to merge it quickly so that I could incorporate this in the changelogs (hidden entry but avoids future release pollution) to include that one.

@@ -244,7 +244,7 @@ def get_link(
:param dttm: datetime
:return: url link
"""
if ti_key:
if ti_key is not None:
Copy link
Member

Choose a reason for hiding this comment

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

This makes no difference does it? (since we don't define a custom book on TIKey)

Copy link
Member Author

@potiuk potiuk Mar 14, 2022

Choose a reason for hiding this comment

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

Nope. But it's easier to standardize as convention. Both ways were used in the code and I arbitrary chose not None as more explicit.

Copy link
Member Author

Choose a reason for hiding this comment

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

This way we have only one "standard" way to check.

@potiuk potiuk closed this Mar 14, 2022
@potiuk potiuk reopened this Mar 14, 2022
@potiuk
Copy link
Member Author

potiuk commented Mar 14, 2022

Random doc inventory problem it seems. Reopened to rebuild.

@potiuk potiuk closed this Mar 14, 2022
@potiuk potiuk reopened this Mar 14, 2022
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Mar 14, 2022
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

The XCom.get_value has been added in 2.3.0 and while there are
cases it should be used in the providers when task are mapped,
in order to keep compatibility with earlier versions of Airlfow,
the XCom.get_value() should only be used when ti_key is not None.

We check for the construct used in community providers automatically
and also add a documentation for users who would like to use
dynamic task mapping featuers in their own providers.
@potiuk potiuk force-pushed the add-protection-against-incompatible-xcom-getvalue-usage branch from 6161beb to 7421d83 Compare March 14, 2022 18:04
@potiuk
Copy link
Member Author

potiuk commented Mar 14, 2022

Rebased to take advantage of the "docs" build fix

@potiuk potiuk merged commit c1ab8e2 into apache:main Mar 14, 2022
@potiuk potiuk deleted the add-protection-against-incompatible-xcom-getvalue-usage branch March 14, 2022 18:38
@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools area:providers full tests needed We need to run full set of tests for this PR to merge kind:documentation provider:amazon-aws AWS/Amazon - related issues provider:google Google (including GCP) related issues provider:microsoft-azure Azure-related issues type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants