xcom_pull logs at ERROR level for an expected "XCom not found" case in Airflow 3.x Task SDK
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- api, backend, observability
Research direction
Start in airflow/sdk/api/client.py at XComOperations.get() and get_sequence_item(), focusing on the handled 404 paths that log “XCom not found.” Adjust the logging level for those expected cases while preserving the existing None-return behavior, then verify the relevant client tests and the optional-XCom workflow behavior.
Written by the indexing model from the issue text.
Description
Description
In Airflow 3.x, TaskInstance.xcom_pull() executed from inside a running task goes through airflow.sdk.api.client.py::XComOperations.get(). When the requested key/task_id doesn't have a matching XCom, the API server returns a 404, which is caught and handled gracefully — the call still returns None, matching Airflow 2.x behavior — but before returning, it logs:
log.error(
"XCom not found",
dag_id=dag_id, run_id=run_id, task_id=task_id, key=key,
map_index=map_index, detail=e.detail, status_code=e.response.status_code,
)
This means every task that does a "check if this XCom exists" style xcom_pull (a very common and valid pattern — pulling with a default, or checking optional upstream output) emits a task-log ERROR line even though nothing failed and no exception propagates. This is confusing for on-call/monitoring setups that alert on ERROR-level task logs, and misrepresents an expected, handled condition as an error.
This behavior was introduced by #45344 (closing #45341), which fixed a real bug — task crashes on missing XCom — by catching the 404 and returning None. That PR's discussion focused entirely on not crashing; the log level wasn't discussed.
Suggested fix
Downgrade these to log.warning (or lower) in airflow/sdk/api/client.py, since the surrounding code explicitly treats the condition as expected/handled, not an error:
XComOperations.get()(~line 535, "XCom not found")XComOperations.get_sequence_item()(~line 606, "XCom not found")
(Possibly also "Asset not found" at ~line 674 for the same reason, though that's a separate call site — happy to split if preferred.)
Workaround
[logging] namespace_levels = airflow.sdk.api.client=CRITICAL in airflow.cfg silences it, but that's an all-or-nothing hammer on the whole client logger (also silences genuine connectivity/auth errors from the same module).
Environment
Observed on Airflow 3.2.2, but the code path is unchanged as of main as far as I can tell.
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
- Dominant language
- Python
- Stars
- 46.9k
- Forks
- 17.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 480
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/airflow
-
kind:bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
area:providers good first issue kind:bug kind:documentation provider:google
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
kind:bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
area:providers kind:bug provider:cncf-kubernetes
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100