Return 404 instead of 500 when workflow not found (#SKY-7256) (#4699)

This commit is contained in:
Celal Zamanoglu
2026-02-11 16:31:38 +03:00
committed by GitHub
parent 5e9c1f4f68
commit cc84c927f2
2 changed files with 42 additions and 25 deletions

View File

@@ -1580,6 +1580,7 @@ async def run_block(
# LOG.critical("REMOVING BROWSER SESSION ID") # LOG.critical("REMOVING BROWSER SESSION ID")
# block_run_request.browser_session_id = None # block_run_request.browser_session_id = None
try:
await block_service.validate_block_labels( await block_service.validate_block_labels(
workflow_permanent_id=block_run_request.workflow_id, workflow_permanent_id=block_run_request.workflow_id,
organization_id=organization.organization_id, organization_id=organization.organization_id,
@@ -1608,6 +1609,15 @@ async def run_block(
browser_session_id=browser_session_id, browser_session_id=browser_session_id,
block_outputs=block_run_request.block_outputs, block_outputs=block_run_request.block_outputs,
) )
except SkyvernHTTPException:
raise
except Exception:
LOG.exception(
"Unexpected error running blocks",
workflow_id=block_run_request.workflow_id,
organization_id=organization.organization_id,
)
raise
return BlockRunResponse( return BlockRunResponse(
block_labels=block_run_request.block_labels, block_labels=block_run_request.block_labels,

View File

@@ -41,6 +41,7 @@ from skyvern.exceptions import (
MissingValueForParameter, MissingValueForParameter,
ScriptTerminationException, ScriptTerminationException,
SkyvernException, SkyvernException,
SkyvernHTTPException,
WorkflowNotFound, WorkflowNotFound,
WorkflowNotFoundForWorkflowRun, WorkflowNotFoundForWorkflowRun,
WorkflowRunNotFound, WorkflowRunNotFound,
@@ -3432,6 +3433,12 @@ class WorkflowService:
) )
return updated_workflow return updated_workflow
except SkyvernHTTPException:
# Bubble up well-formed client errors (e.g. WorkflowNotFound 404)
# so they are not wrapped in a 500 by the caller.
if new_workflow_id:
await self.delete_workflow_by_id(workflow_id=new_workflow_id, organization_id=organization_id)
raise
except Exception as e: except Exception as e:
if new_workflow_id: if new_workflow_id:
LOG.error( LOG.error(