Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Return 404 instead of 500 when workflow not found (#SKY-7256) (#4699)
Celal Zamanoglucc84c927f2fc
diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.pyindex 894ded34a..0589730b0 100644--- a/skyvern/forge/sdk/routes/agent_protocol.py+++ b/skyvern/forge/sdk/routes/agent_protocol.py@@ -1580,34 +1580,44 @@ async def run_block(# LOG.critical("REMOVING BROWSER SESSION ID")# block_run_request.browser_session_id = None- await block_service.validate_block_labels(- workflow_permanent_id=block_run_request.workflow_id,- organization_id=organization.organization_id,- block_labels=block_run_request.block_labels,- )+ try:+ await block_service.validate_block_labels(+ workflow_permanent_id=block_run_request.workflow_id,+ organization_id=organization.organization_id,+ block_labels=block_run_request.block_labels,+ )- workflow_run = await block_service.ensure_workflow_run(- organization=organization,- template=template,- workflow_permanent_id=block_run_request.workflow_id,- block_run_request=block_run_request,- )+ workflow_run = await block_service.ensure_workflow_run(+ organization=organization,+ template=template,+ workflow_permanent_id=block_run_request.workflow_id,+ block_run_request=block_run_request,+ )- browser_session_id = block_run_request.browser_session_id+ browser_session_id = block_run_request.browser_session_id- await block_service.execute_blocks(- request=request,- background_tasks=background_tasks,- api_key=x_api_key or "",- block_labels=block_run_request.block_labels,- workflow_id=block_run_request.workflow_id,- workflow_run_id=workflow_run.workflow_run_id,- workflow_permanent_id=workflow_run.workflow_permanent_id,- organization=organization,- user_id=user_id,- browser_session_id=browser_session_id,- block_outputs=block_run_request.block_outputs,- )+ await block_service.execute_blocks(+ request=request,+ background_tasks=background_tasks,+ api_key=x_api_key or "",+ block_labels=block_run_request.block_labels,+ workflow_id=block_run_request.workflow_id,+ workflow_run_id=workflow_run.workflow_run_id,+ workflow_permanent_id=workflow_run.workflow_permanent_id,+ organization=organization,+ user_id=user_id,+ browser_session_id=browser_session_id,+ 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,+ )+ raisereturn BlockRunResponse(block_labels=block_run_request.block_labels,diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.pyindex 7b7961f26..f6d29d9ae 100644--- a/skyvern/forge/sdk/workflow/service.py+++ b/skyvern/forge/sdk/workflow/service.py@@ -41,6 +41,7 @@ from skyvern.exceptions import (MissingValueForParameter,ScriptTerminationException,SkyvernException,+ SkyvernHTTPException,WorkflowNotFound,WorkflowNotFoundForWorkflowRun,WorkflowRunNotFound,@@ -3432,6 +3433,12 @@ class WorkflowService:)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)+ raiseexcept Exception as e:if new_workflow_id:LOG.error(