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

Disallow using an empty key in XCom pull #46925

Open
1 task done
vatsrahul1001 opened this issue Feb 20, 2025 · 4 comments
Open
1 task done

Disallow using an empty key in XCom pull #46925

vatsrahul1001 opened this issue Feb 20, 2025 · 4 comments
Assignees
Labels
affected_version:3.0.0alpha For all 3.0.0 alpha releases area:core good first issue kind:meta High-level information important to the community

Comments

@vatsrahul1001
Copy link
Collaborator

vatsrahul1001 commented Feb 20, 2025

Body

Currently we allow this pulled_value_1 = ti.xcom_pull(key="", task_ids="push"). We should not allow sending empty keys

pulled_value_1 = ti.xcom_pull(key=None, task_ids="push")

Eventually leads to:

    @staticmethod
    @provide_session
    def get_many(
        *,
        run_id: str,
        key: str | None = None,
        task_ids: str | Iterable[str] | None = None,
        dag_ids: str | Iterable[str] | None = None,
        map_indexes: int | Iterable[int] | None = None,
        include_prior_dates: bool = False,
        limit: int | None = None,
        session: Session = NEW_SESSION,
    ) -> Query:
        """
        Composes a query to get one or more XCom entries.

        This function returns an SQLAlchemy query of full XCom objects. If you
        just want one stored value, use :meth:`get_one` instead.

        :param run_id: DAG run ID for the task.
        :param key: A key for the XComs. If provided, only XComs with matching
            keys will be returned. Pass *None* (default) to remove the filter.

Here we see that a non empty value for "key" disables the filter (no where(XCom.key == key), it does not filter for None.

This is how it looks:

if key:
    query = query.filter(BaseXCom.key == key)

It really doesn't make any sense to have an xcom with "" as key.

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.
@vatsrahul1001 vatsrahul1001 added affected_version:3.0.0alpha For all 3.0.0 alpha releases good first issue kind:meta High-level information important to the community labels Feb 20, 2025
@dosubot dosubot bot added the area:core label Feb 20, 2025
@felipe-henao
Copy link

should this just be rejected or pull the return value from the push task?

@amoghrajesh
Copy link
Contributor

amoghrajesh commented Feb 20, 2025

@kiran2706 next time you are working on something, get the issue assigned to yourself so that the issue has an assignee and multiple people arent working on it

@kiran2706
Copy link

@amoghrajesh or @vatsrahul1001 - Could you please assign this issue to me?

@amoghrajesh
Copy link
Contributor

Assigned to you

@amoghrajesh amoghrajesh marked this as a duplicate of #46417 Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected_version:3.0.0alpha For all 3.0.0 alpha releases area:core good first issue kind:meta High-level information important to the community
Projects
None yet
Development

No branches or pull requests

4 participants