Fix execution API token access checks #60431
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix execution API token access checks for connections, variables, and XComs by requiring a valid TaskInstance and tightening XCom read/write rules. Also refreshes a small doc note and removes stale TODOs.
Issue
Solution
Implementation details
uv sync --all-packagesis required when running airflow-core tests that still touch provider deps.Low-level changes
airflow-core/src/airflow/api_fastapi/execution_api/deps.py: addget_task_instance_from_tokenand reuse it in access checks.airflow-core/src/airflow/api_fastapi/execution_api/routes/xcoms.py: enforce TI-based read/write restrictions and log usingti.id.airflow-core/src/airflow/api_fastapi/execution_api/routes/variables.py: validate TI presence before variable access.airflow-core/src/airflow/api_fastapi/execution_api/routes/connections.py: validate TI presence before connection access.airflow-core/tests/unit/api_fastapi/execution_api/conftest.py: addauth_headersfixture and token parsing logic in the JWT validator mock.airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_connections.py: add missing-TI denial test and use auth headers for existing coverage.airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_variables.py: add missing-TI denial test and update access-denied override to call the real guard.airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_xcoms.py: add read/write denial tests and route auth through TI tokens.airflow-core/src/airflow/api_fastapi/common/db/common.py: clarify that permission filtering happens via route-level filters.airflow-core/src/airflow/api_fastapi/execution_api/routes/assets.py: remove stale JWT TODO comment.airflow-core/src/airflow/api_fastapi/execution_api/routes/asset_events.py: remove stale JWT TODO comment.contributing-docs/07_local_virtualenv.rst: clarifyuv sync --all-packagesrequirement (remove TODO).Impact
Tests
PATH=$PWD/.venv/bin:$PATH UV_CACHE_DIR=$PWD/.cache/uv AIRFLOW_HOME=$PWD/.airflow .venv/bin/pytest -p no:rerunfailures airflow-core/tests/unit/api_fastapi/execution_api/versions/headPATH=$PWD/.venv/bin:$PATH ~/.local/bin/breeze testing core-tests --backend mysql --db-reset airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py::TestTIUpdateState::test_ti_update_state_reschedule_mysql_limitSuggested reviewers
Was generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex following https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions