Skip to content

Commit

Permalink
fix: prevent runs filter from accepting an empty list of run ids (#7217)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexledesma committed Mar 29, 2022
1 parent fd7189a commit 7abf706
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def to_selector(self):
created_before = pendulum.from_timestamp(self.createdBefore) if self.createdBefore else None

return RunsFilter(
run_ids=self.runIds,
run_ids=self.runIds if self.runIds else None,
pipeline_name=self.pipelineName,
tags=tags,
statuses=statuses,
Expand Down
3 changes: 3 additions & 0 deletions python_modules/dagster/dagster/core/storage/pipeline_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ def __new__(
pipeline_name: Optional[str] = None, # for backcompat purposes
):
job_name = job_name or pipeline_name

check.invariant(run_ids != [], "When filtering on run ids, a non-empty list must be used.")

return super(RunsFilter, cls).__new__(
cls,
run_ids=check.opt_list_param(run_ids, "run_ids", of_type=str),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest

from dagster import check
from dagster.check import CheckError
from dagster.core.code_pointer import ModuleCodePointer
from dagster.core.definitions.reconstruct import ReconstructableRepository
from dagster.core.host_representation.origin import (
Expand All @@ -20,6 +21,7 @@
NON_IN_PROGRESS_RUN_STATUSES,
PipelineRun,
PipelineRunStatus,
RunsFilter,
)


Expand Down Expand Up @@ -68,3 +70,11 @@ def test_in_progress_statuses():
assert len(IN_PROGRESS_RUN_STATUSES) + len(NON_IN_PROGRESS_RUN_STATUSES) == len(
PipelineRunStatus
)


def test_runs_filter_supports_nonempty_run_ids():
assert RunsFilter()
assert RunsFilter(run_ids=["1234"])

with pytest.raises(CheckError):
RunsFilter(run_ids=[])

0 comments on commit 7abf706

Please sign in to comment.