Repository navigation
Fix XCom get_value outside task runner - #68789
sdhilip200 wants to merge 1 commit into
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
|
Hi, I don't think this is the right approach. The task-sdk should not be accessing the database directly. I would take a look at the docs here for a bit more detail on database access restrictions: |
cc8f502 to
cee3476
Compare
|
Updated the PR in cee3476 to avoid DB access from task-sdk. The revised patch restores BaseXCom to the supervisor-comms-only path, adds server-side XComModel.get_one()/get_value() helpers, exposes XComModel from the common compat SDK for plugin extra links, and adds /links route coverage for a plugin-registered extra link reading XCom through XComModel. |
This comment was marked as spam.
This comment was marked as spam.
cee3476 to
5a6f988
Compare
|
Updated in 5a6f988.
I also added Verified locally on the rebased branch:
|
The new changes avoid the task-sdk db access issue, but I'm not sure exposing XComModel through the compat sdk is the correct approach either as it's mixing server and task imports in the same module. That being said, I'm not an expert here so I will defer to a maintainer. Just curious, did you take a look at the proposed solution on the issue? It avoids the need for any of these changes by having the plugin use XComModel and create_session directly from core |
5a6f988 to
990456d
Compare
|
Updated in 990456d to add the This addresses the Verified locally with: uv run breeze ci selective-check --commit-ref HEAD --pr-labels "['area:task-sdk']" --github-event-name pull_request --github-repository apache/airflow --github-actor sdhilip200The local check now reports: |
f35e744 to
7534804
Compare
|
Updated in 7534804 to make the common.compat sdk.XComModel test Airflow-version aware. The compat test now asserts XComModel on Airflow 3 and the XCom fallback on Airflow 2, matching the compat rename map. This addresses the Compat 2.11.1 provider distribution failure. Verified locally with: uv run pytest --rootdir=providers/common/compat providers/common/compat/tests/unit/common/compat/test_sdk.py; uv run ruff check providers/common/compat/tests/unit/common/compat/test_sdk.py; uv run ruff format --check providers/common/compat/tests/unit/common/compat/test_sdk.py; git diff --check. |
7534804 to
7ac3b14
Compare
|
Updated in 7ac3b14 to make the XComObjectStorageBackend regression run only when the installed Airflow exposes the new server-side XComModel helpers added by this PR. This keeps the object-storage backend regression active for the current implementation while preventing provider-compat jobs for released Airflow 3 wheels from failing on missing get_value or set(..., serialize=False) support. Verified locally with uv run pytest --rootdir=providers/common/io providers/common/io/tests/unit/common/io/xcom/test_backend.py -k xcommodel_get_value_uses_configured_backend. Also verified uv run ruff check providers/common/io/tests/unit/common/io/xcom/test_backend.py, uv run ruff format --check providers/common/io/tests/unit/common/io/xcom/test_backend.py, git diff --check, and uv run scripts/ci/prek/update_providers_dependencies.py with no generated-file diff. |
7ac3b14 to
10c068a
Compare
10c068a to
d8b1907
Compare
|
Updated in d8b1907 to fix the static-check failure from check-airflow-v-imports-in-tests by importing AIRFLOW_V_3_0_PLUS from tests_common.test_utils.version_compat at module scope in the common.compat SDK test. Verified locally: python3 -m py_compile providers/common/compat/tests/unit/common/compat/test_sdk.py; uv run ruff check providers/common/compat/tests/unit/common/compat/test_sdk.py; uv run ruff format --check providers/common/compat/tests/unit/common/compat/test_sdk.py; uv run pytest --rootdir=providers/common/compat providers/common/compat/tests/unit/common/compat/test_sdk.py; git diff --check. I also inspected the provider-distribution compat failures in the same run; they fail while collecting providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_data_factory.py because FactoryListResponse is missing from azure.mgmt.datafactory.models, which is outside this PR's changed files. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions. |
|
Does this need new API on |
Plugin-registered extra links are resolved in the API server, but examples can naturally reach for
XCom.get_value()from the SDK/compat SDK. In Airflow 3 that SDK XCom path is task-runner scoped, so it expectsSUPERVISOR_COMMSand is not suitable for API-server extra-link code.This adds a server-side
XComModel.get_one()/XComModel.get_value()convenience path that reuses the existing metadata DB query. For the default backend it preservesXComModelJSON-row deserialization, and for configured custom XCom backends it routes the stored row through the configured backend so server-side extra-link code keeps the compat behavior of resolving the actual XCom value rather than an object-storage reference.The common compat SDK now exposes
XComModel, so plugin extra links can use an API-server-safe XCom reader without importing task-runtime SDK XCom.This also adds route coverage showing a plugin-registered extra link resolving through
/linksand reading an XCom value withXComModel.get_value(), plusXComObjectStorageBackendregression coverage for custom backend deserialization.Closes #59093
Tests:
uv run pytest --rootdir=providers/common/io providers/common/io/tests/unit/common/io/xcom/test_backend.py::TestXComObjectStorageBackenduv run pytest airflow-core/tests/unit/models/test_xcom.py airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_extra_links.py task-sdk/tests/task_sdk/bases/test_xcom.pyuv run pytest --rootdir=providers/common/compat providers/common/compat/tests/unit/common/compat/test_sdk.pyuv run ruff check airflow-core/src/airflow/models/xcom.py airflow-core/tests/unit/models/test_xcom.py airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_extra_links.py providers/common/compat/src/airflow/providers/common/compat/sdk.py providers/common/compat/tests/unit/common/compat/test_sdk.py providers/common/io/tests/unit/common/io/xcom/test_backend.pyuv run ruff format --check airflow-core/src/airflow/models/xcom.py airflow-core/tests/unit/models/test_xcom.py airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_extra_links.py providers/common/compat/src/airflow/providers/common/compat/sdk.py providers/common/compat/tests/unit/common/compat/test_sdk.py providers/common/io/tests/unit/common/io/xcom/test_backend.pygit diff --checkWas generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions