Skip to content

Commit

Permalink
Add bad request response when pipeline run not in terminable state
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf committed Nov 6, 2024
1 parent 3e4292d commit d83e6af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/api/src/backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@
(RUN_STATUS_DEFERRED, "deferred")
]

TERMINAL_STATUSES = [RUN_STATUS_FAILED, RUN_STATUS_COMPLETED, RUN_STATUS_TERMINATED]

EXEC_STATUS_PENDING = "pending"
EXEC_STATUS_ACTIVE = "active"
EXEC_STATUS_STAGING = "staging"
Expand Down
5 changes: 4 additions & 1 deletion src/api/src/backend/views/PipelineRuns.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BadRequest
)
from backend.services.GroupService import service as group_service
from backend.models import PipelineRun, Pipeline
from backend.models import PipelineRun, Pipeline, TERMINAL_STATUSES
from backend.helpers.PipelineDispatchRequestBuilder import PipelineDispatchRequestBuilder
from backend.services.PipelineDispatcher import service as pipeline_dispatcher
from backend.errors.api import ServerError
Expand Down Expand Up @@ -61,6 +61,9 @@ def post(self, request, group_id, pipeline_id, pipeline_run_uuid):

if not pipeline_run:
return BadRequest(f"PiplineRun with uuid '{pipeline_run_uuid}' does not exist")

if pipeline_run.status not in TERMINAL_STATUSES:
return BadRequest(f"PiplineRun with uuid '{pipeline_run_uuid}' is not in a terminable state")

try:
# Build the pipeline dispatch request
Expand Down

0 comments on commit d83e6af

Please sign in to comment.