Skip to content

Fix XCom PATCH/POST to store native values (instead of json.dumps)#64220

Open
henry3260 wants to merge 2 commits intoapache:mainfrom
henry3260:Correct-xcom-patch-API
Open

Fix XCom PATCH/POST to store native values (instead of json.dumps)#64220
henry3260 wants to merge 2 commits intoapache:mainfrom
henry3260:Correct-xcom-patch-API

Conversation

@henry3260
Copy link
Copy Markdown
Contributor

@henry3260 henry3260 commented Mar 25, 2026

Why

The public Core API's create_xcom_entry and update_xcom_entry previously used json.dumps(patch_body.value) when storing values in the XComModel.value JSON column. This caused "excessively serialized" values (strings or None) when tasks called xcom_pull(include_prior_dates=True) to retrieve XComs from past DagRuns.

closes: #59032

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Mar 25, 2026
@henry3260 henry3260 changed the title Fix XCom PATCH/POST to store native values (instead of json.dumps str… Fix XCom PATCH/POST to store native values (instead of json.dumps) Mar 25, 2026
@henry3260 henry3260 force-pushed the Correct-xcom-patch-API branch 2 times, most recently from 8fab5a6 to 4cc53f0 Compare March 26, 2026 04:30
@henry3260 henry3260 marked this pull request as ready for review March 26, 2026 13:33
Copy link
Copy Markdown
Contributor

@bugraoz93 bugraoz93 left a comment

Choose a reason for hiding this comment

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

Look good to me! .set() already always does delete and insert. It ensures the object in the model is rendered from .set(). This should resolve it.

@amoghrajesh, could you please also check?

@bugraoz93 bugraoz93 added the affected_version:3.2.0beta Use for reporting issues with 3.2.0beta label Mar 26, 2026
Copy link
Copy Markdown
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Look good to me! .set() already always does delete and insert. It ensures the object in the model is rendered from .set(). This should resolve it.

Yeah, LGTM as well. Thanks for the fix!

Copy link
Copy Markdown
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.

I tested this, just one query, but looks good otherwise

Image

xcom = session.scalar(
select(XComModel)
.filter(
.where(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why this change?

Hi @amoghrajesh, I updated this to align with the modern SQLAlchemy 2.0 syntax. While .filter() still works here, .where() is the canonical method when using select() constructs.
Let me know if you'd prefer I revert this part.

@eladkal eladkal added this to the Airflow 3.2.0 milestone Mar 27, 2026
@henry3260 henry3260 force-pushed the Correct-xcom-patch-API branch from d07ee04 to 5cef09b Compare March 27, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affected_version:3.2.0beta Use for reporting issues with 3.2.0beta area:API Airflow's REST/HTTP API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correct xcom patch API to be usable with tasks

5 participants