Skip to content

Render XCom values on the API server without rebuilding objects - #74829

Merged
potiuk merged 2 commits into
apache:mainfrom
potiuk:api-xcom-read-without-object-reconstruction
Oct 19, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
potiuk:api-xcom-read-without-object-reconstruction

Conversation

@potiuk

@potiuk potiuk commented Oct 15, 2026

Copy link
Copy Markdown
Member

GET .../xcomEntries/{key}?deserialize=true renders stored values with
stringify(), but fell back to XComModel.deserialize_value() for any
airflow.* class. That fallback runs full serde in the API server just to turn
the result back into a string for the response. The API server only needs the
readable form, so it does not have to rebuild the objects at all. This follows
the "full serde shouldn't run on the API server" direction from the review
of #73625, and matches the scheduler-side change in #72718.

stringify() now renders airflow.* classes from their serialized fields,
without importing them. For attrs/dataclass types like Asset and
AssetAlias, the output is the same repr-style text as before, e.g.
AssetAlias(name='x', group='asset'). Nested non-Airflow classes keep the
existing module.Class@version=N(...) form. Because nothing raises
StringifyNotSupportedError any more, the fallback is removed from the XCom
endpoint and the XComOperatorLink extra-link lookup.

Response shapes and the OpenAPI schema are unchanged. deserialize=false and
stringify=true behave as before. The Execution API write path is untouched.

Tests:

  • uv run pytest for the XCom route tests (90 passed), test_stringify.py
    (53 passed), test_operatorlink.py (2 passed), test_extra_links.py
    (28 passed) and utils/test_json.py (11 passed)
  • The new route, stringify and operator-link tests fail without the change
  • prek run --files on the changed files: all hooks pass except
    Generate the FastAPI API spec, which needs the Breeze CI image. The change
    does not touch any route signature or datamodel.

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

Generated-by: Claude Opus 5 following the guidelines


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

`GET .../xcomEntries/{key}?deserialize=true` fell back to
`XComModel.deserialize_value()` for any `airflow.*` class, running full
serde in the API server only to turn the result back into a string.
`stringify()` now renders `airflow.*` classes from their serialized
fields without importing them, producing the same repr-style output for
attrs/dataclass types, so the fallback is removed from the XCom endpoint
and the `XComOperatorLink` extra-link lookup.

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
…splay

Only asset definitions, which are attrs types, have serialized fields that
mirror their repr. Other Airflow classes can define serialize() returning
internal state that their repr never shows, e.g. the storage options kept
by ObjectStoragePath. Show those by their path or URI only.

Generated-by: Claude Opus 5 following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
@potiuk

potiuk commented Oct 16, 2026 •

Copy link
Copy Markdown
Member Author

@pierrejeambrun @ashb Could you take a look at this when you have a moment? It's targeted at 3.4.0 and needs a review to make the cut on 2026-10-19. CI is green. It goes together with #72718.

@vatsrahul1001 vatsrahul1001 left a comment •

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.

Looks good to me. stringify now renders airflow.* classes from their serialized fields without importing them, the tests compare against the real repr for assets, and nothing else imported StringifyNotSupportedError.Could use reviews from @pierrejeambrun @ashb before merging.

@potiuk
potiuk merged commit b107f60 into apache:main Oct 19, 2026
85 checks passed
@potiuk
potiuk deleted the api-xcom-read-without-object-reconstruction branch October 19, 2026 10:42
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:DAG-processing backport-to-v3-4-test Backport to v3-4-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants