jason810496 commented on code in PR #46929:
URL: https://github.com/apache/airflow/pull/46929#discussion_r2051684930
##########
airflow-core/tests/unit/models/test_xcom.py:
##########
@@ -333,6 +333,26 @@ def test_xcom_get_many_from_prior_dates(self, session,
tis_for_xcom_get_many_fro
)
assert [x.logical_date for x in stored_xcoms] == [ti2.logical_date,
ti1.logical_date]
+ def test_xcom_get_invalid_key(self, session, task_instance):
+ """Test that getting an XCom with an invalid key raises a
ValueError."""
+ with pytest.raises(ValueError, match="XCom key must be a non-empty
string. Received: ''"):
+ XComModel.get_many(
+ key="", # Invalid key
+ dag_ids=task_instance.dag_id,
+ task_ids=task_instance.task_id,
+ run_id=task_instance.run_id,
+ session=session,
+ )
+
+ with pytest.raises(ValueError, match="XCom key must be a non-empty
string. Received: None"):
+ XComModel.get_many(
+ key=None, # Invalid key
+ dag_ids=task_instance.dag_id,
+ task_ids=task_instance.task_id,
+ run_id=task_instance.run_id,
+ session=session,
+ )
+
Review Comment:
Thanks for adding the test.
However, it still needs to be fixed:
https://github.com/apache/airflow/actions/runs/14557855530/job/40837342564?pr=46929#step:6:2236
I’ll mark the PR as draft for now. Feel free to reopen it for review once
the issue is resolved!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]