Skip to content

Commit

Permalink
Check dataset_alias exists in inlets when use it to retrieve inlet_ev…
Browse files Browse the repository at this point in the history
…ents (apache#41043)
  • Loading branch information
Lee-W authored Jul 26, 2024
1 parent 277e746 commit f0ef691
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion airflow/utils/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ def __getitem__(self, key: int | str | Dataset | DatasetAlias) -> LazyDatasetEve
obj = key

if isinstance(obj, DatasetAlias):
dataset_alias = self._dataset_aliases[obj.name]
join_clause = DatasetEvent.source_aliases
where_clause = DatasetAliasModel.name == obj.name
where_clause = DatasetAliasModel.name == dataset_alias.name
elif isinstance(obj, (Dataset, str)):
dataset = self._datasets[extract_event_key(obj)]
join_clause = DatasetEvent.dataset
Expand Down
2 changes: 2 additions & 0 deletions tests/models/test_taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,8 @@ def read(*, inlet_events):

with pytest.raises(KeyError):
inlet_events["does_not_exist"]
with pytest.raises(KeyError):
inlet_events[DatasetAlias("does_not_exist")]
with pytest.raises(IndexError):
inlet_events[DatasetAlias(dsa_name)][5]

Expand Down

0 comments on commit f0ef691

Please sign in to comment.