Refactor xcom API to use shared serialisation constants#64148
Refactor xcom API to use shared serialisation constants#64148amoghrajesh merged 11 commits intoapache:mainfrom
Conversation
ee023d0 to
b924f6f
Compare
shared/serialization/src/airflow_shared/serialization/__init__.py
Outdated
Show resolved
Hide resolved
airflow-core/src/airflow/api_fastapi/core_api/routes/public/xcom.py
Outdated
Show resolved
Hide resolved
|
I wonder if it’d be easier to just use pre-commit hooks to keep two files in core and sdk in sync instead of a shared module |
Easier, yes, but I am not highly in favour of that @uranusjr, the shared library seems to be a much more maintainable approach even for such small utilities. With prek hook here, refactors etc could lose the source of truth making it harder to track and maintain over time leading to a drift risk. |
pierrejeambrun
left a comment
There was a problem hiding this comment.
Just one nit, otherwise this makes sense to me.
airflow-core/src/airflow/api_fastapi/core_api/routes/public/xcom.py
Outdated
Show resolved
Hide resolved
e721a59 to
643c514
Compare
|
The failures here are unrelated, like this: Provider yandex is not excluded.
Ignoring existing lockfile due to change in resolution mode: `highest` vs. `lowest-direct`
warning: The direct dependency `setuptools` is unpinned. Consider setting a lower bound when using `--resolution lowest` or `--resolution lowest-direct` to avoid using outdated versions.
warning: The direct dependency `pyspark` is unpinned. Consider setting a lower bound when using `--resolution lowest` or `--resolution lowest-direct` to avoid using outdated versions.
warning: The direct dependency `pydantic-ai-slim` is unpinned. Consider setting a lower bound when using `--resolution lowest` or `--resolution lowest-direct` to avoid using outdated versions.
warning: The direct dependency `pytest` is unpinned. Consider setting a lower bound when using `--resolution lowest` or `--resolution lowest-direct` to avoid using outdated versions.
Resolved 928 packages in 8.26s
Building apache-airflow-providers-yandex @ file:///opt/airflow/providers/yandex
Downloading yandexcloud (5.4MiB)
Built apache-airflow-providers-yandex @ file:///opt/airflow/providers/yandex
Downloaded yandexcloud
× Failed to download and build `grpcio-tools==1.71.2`
├─▶ Failed to acquire lock on the distribution cache
├─▶ Could not acquire lock
╰─▶ Timeout (300s) when waiting for lock on
`/root/.cache/uv/sdists-v9/pypi/grpcio-tools/1.71.2` at
`/root/.cache/uv/sdists-v9/pypi/grpcio-tools/1.71.2/.lock`, is another
uv process running? You can set `UV_LOCK_TIMEOUT` to increase the
timeout.
help: `grpcio-tools` (v1.71.2) was included because
`apache-airflow-providers-yandex` (v4.4.1) depends on `yandexcloud`
(v0.376.0) which depends on `grpcio-tools` |
jason810496
left a comment
There was a problem hiding this comment.
LGTM as well, thanks for the improvement.
Non-blocking nits.
Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Updated test docstring to clarify purpose.
|
Okay unrelated failures. Merging this. |


I wasn't anticipating that we would need this initially, but turns out we lose abilities of
XcomEncoder/XcomDecoderif we do not use them as it was removed in: #58900. The ability lost here is disallowing the internal keys like_classname,_typesetc.However, we cannot go back to the old way of importing
XcomEncoderagain because it internally importsairflow.sdk.serdeand we do not want to bring back the dependency of sdk in core that we worked hard to remove.The ideal solution to this would be to move serialization format constants (classname, __type, __var, etc.)
to a new shared library and consume those across airflow-core and task-sdk. This also brings back the validation in XCom API to reject reserved serialization keys in user-provided data and update read path to avoid unnecessary deserialization.
After changes this is how it looks

Was generative AI tooling used to co-author this PR?
{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.