Fix cross-DAG xcom_pull with include_prior_dates=True returning None (#70173)#70199
Fix cross-DAG xcom_pull with include_prior_dates=True returning None (#70173)#70199Pranaykarvi wants to merge 2 commits into
Conversation
…pache#70173) Signed-off-by: Pranay Kumar Karvi <pranaykarvi@gmail.com>
baa7b7c to
8cb8e21
Compare
|
@kaxil @amoghrajesh One call-out: same-DAG Locally: 94 passed incl. 2 new regression tests; both fail before the fix. |
closes #70173
What
Cross-DAG
xcom_pull(..., include_prior_dates=True)returnedNoneon Airflow 3.2.x / 3.3.0 (regression from 3.1.7). The upstream XCom is written correctly; only the cross-DAG read fails.Root cause
XComModel.get_manyderived theinclude_prior_datescutoff with a correlated scalar subquery keyed onDagRun.run_id == run_id AND DagRun.dag_id == cls.dag_id. On a cross-DAG pull the request carriesdag_id = <target/upstream>butrun_id = <caller's own run>, so no matchingDagRunexists (cls.dag_idis the upstream DAG). The subquery resolves to NULL, the<=predicate is NULL, every row is filtered out, and the SDK falls back toNone. Same-DAG pulls worked becauserun_idanddag_idagree.The
cls.dag_idscoping was intentional — it disambiguatesrun_idcollisions across DAGs — so the fix keeps the caller's DAG rather than dropping the scoping.Fix
include_prior_datessemantically means "XComs on or before the pulling task instance's own run date" (matching 3.1/2.x). The caller is identified server-side by the TI token, so the Execution API resolves the cutoff from the caller's own DAG run and passes it toget_manyvia a new optionalprior_dates_before. When it's set, the query bounds directly on it; when it'sNone, the original correlated-subquery path is kept as a fallback for direct model-level callers. No SDK, schema, or API-version change —include_prior_dateswas already parsed on both filter params.Behavioral note
Because the cutoff now comes from the caller's TI, a same-DAG
xcom_pull(run_id=<earlier run>, include_prior_dates=True)is bounded by the caller's run date rather than that explicit run's date. This restores pre-3.2 semantics (the reference was always the pulling TI's date), but it's a subtle change in that edge combination and is called out here intentionally.Tests
test_xcom_get_many_from_prior_dates_cross_dag(model): cross-DAG pull returns the upstream value.test_xcom_get_include_prior_dates_cross_dag(route): end-to-end reproduction of xcom include_prior_dates=True returns "None" instead of xcom #70173 throughget_xcom.test_xcom_get_many_from_prior_datesand..._scopes_run_id_to_dagunchanged and passing.Both new tests fail before the fix (model:
TypeErroronprior_dates_before; route:404/None, the exact reported symptom).