Skip to content

Disallow deleting workflow processes through the API #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion orchestrator/api/api_v1/endpoints/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def delete(process_id: UUID) -> None:
if not process:
raise_status(HTTPStatus.NOT_FOUND)

if not process.is_task:
raise_status(HTTPStatus.BAD_REQUEST)

db.session.delete(db.session.get(ProcessTable, process_id))
db.session.commit()

Expand Down Expand Up @@ -270,7 +273,7 @@ def update_progress_on_awaiting_process_endpoint(
@router.put(
"/resume-all", response_model=ProcessResumeAllSchema, dependencies=[Depends(check_global_lock, use_cache=False)]
)
async def resume_all_processess_endpoint(request: Request, user: str = Depends(user_name)) -> dict[str, int]:
async def resume_all_processes_endpoint(request: Request, user: str = Depends(user_name)) -> dict[str, int]:
"""Retry all task processes in status Failed, Waiting, API Unavailable or Inconsistent Data.

The retry is started in the background, returning status 200 and number of processes in message.
Expand Down
15 changes: 14 additions & 1 deletion test/unit_tests/api/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,20 @@ def test_show_not_found(test_client, started_process):
assert HTTPStatus.NOT_FOUND == response.status_code


def test_delete_process(responses, test_client, started_process):
def test_delete_process_workflow(responses, test_client, started_process):
processes = test_client.get("/api/processes").json()
before_delete_count = len(processes)

response = test_client.delete(f"/api/processes/{started_process}")
assert HTTPStatus.BAD_REQUEST == response.status_code
assert before_delete_count == len(test_client.get("/api/processes").json())


def test_delete_process_task(responses, test_client, started_process):
process = db.session.get(ProcessTable, started_process)
process.is_task = True
db.session.commit()

processes = test_client.get("/api/processes").json()
before_delete_count = len(processes)

Expand Down