add organization_id filter for get_workflow and get_workflow_run (#1422)
This commit is contained in:
@@ -351,8 +351,14 @@ class BaseTaskBlock(Block):
|
||||
# initial value for will_retry is True, so that the loop runs at least once
|
||||
will_retry = True
|
||||
current_running_task: Task | None = None
|
||||
workflow_run = await app.WORKFLOW_SERVICE.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
workflow = await app.WORKFLOW_SERVICE.get_workflow(workflow_id=workflow_run.workflow_id)
|
||||
workflow_run = await app.WORKFLOW_SERVICE.get_workflow_run(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
workflow = await app.WORKFLOW_SERVICE.get_workflow(
|
||||
workflow_id=workflow_run.workflow_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
# if the task url is parameterized, we need to get the value from the workflow run context
|
||||
if self.url and workflow_run_context.has_parameter(self.url) and workflow_run_context.has_value(self.url):
|
||||
task_url_parameter_value = workflow_run_context.get_value(self.url)
|
||||
|
||||
@@ -191,7 +191,7 @@ class WorkflowService:
|
||||
) -> WorkflowRun:
|
||||
"""Execute a workflow."""
|
||||
organization_id = organization.organization_id
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id, organization_id=organization_id)
|
||||
workflow = await self.get_workflow(workflow_id=workflow_run.workflow_id, organization_id=organization_id)
|
||||
|
||||
# Set workflow run status to running, create workflow run parameters
|
||||
@@ -219,7 +219,8 @@ class WorkflowService:
|
||||
for block_idx, block in enumerate(blocks):
|
||||
try:
|
||||
refreshed_workflow_run = await app.DATABASE.get_workflow_run(
|
||||
workflow_run_id=workflow_run.workflow_run_id
|
||||
workflow_run_id=workflow_run.workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
if refreshed_workflow_run and refreshed_workflow_run.status == WorkflowRunStatus.canceled:
|
||||
LOG.info(
|
||||
@@ -358,7 +359,10 @@ class WorkflowService:
|
||||
await self.clean_up_workflow(workflow=workflow, workflow_run=workflow_run, api_key=api_key)
|
||||
return workflow_run
|
||||
|
||||
refreshed_workflow_run = await app.DATABASE.get_workflow_run(workflow_run_id=workflow_run.workflow_run_id)
|
||||
refreshed_workflow_run = await app.DATABASE.get_workflow_run(
|
||||
workflow_run_id=workflow_run.workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
if refreshed_workflow_run and refreshed_workflow_run.status not in (
|
||||
WorkflowRunStatus.canceled,
|
||||
WorkflowRunStatus.failed,
|
||||
@@ -570,8 +574,11 @@ class WorkflowService:
|
||||
status=WorkflowRunStatus.canceled,
|
||||
)
|
||||
|
||||
async def get_workflow_run(self, workflow_run_id: str) -> WorkflowRun:
|
||||
workflow_run = await app.DATABASE.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
async def get_workflow_run(self, workflow_run_id: str, organization_id: str | None = None) -> WorkflowRun:
|
||||
workflow_run = await app.DATABASE.get_workflow_run(
|
||||
workflow_run_id=workflow_run_id,
|
||||
organization_id=organization_id,
|
||||
)
|
||||
if not workflow_run:
|
||||
raise WorkflowRunNotFound(workflow_run_id)
|
||||
return workflow_run
|
||||
@@ -734,7 +741,7 @@ class WorkflowService:
|
||||
workflow_run_id: str,
|
||||
organization_id: str,
|
||||
) -> WorkflowRunStatusResponse:
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id, organization_id=organization_id)
|
||||
if workflow_run is None:
|
||||
LOG.error(f"Workflow run {workflow_run_id} not found")
|
||||
raise WorkflowRunNotFound(workflow_run_id=workflow_run_id)
|
||||
@@ -756,7 +763,7 @@ class WorkflowService:
|
||||
LOG.error(f"Workflow {workflow_permanent_id} not found")
|
||||
raise WorkflowNotFound(workflow_permanent_id=workflow_permanent_id)
|
||||
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id)
|
||||
workflow_run = await self.get_workflow_run(workflow_run_id=workflow_run_id, organization_id=organization_id)
|
||||
workflow_run_tasks = await app.DATABASE.get_tasks_by_workflow_run_id(workflow_run_id=workflow_run_id)
|
||||
screenshot_artifacts = []
|
||||
screenshot_urls: list[str] | None = None
|
||||
|
||||
Reference in New Issue
Block a user