mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-30 00:07:30 +00:00
fix: check stopping or restarting a step against the run it belongs to
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6eae2d55f8
commit
e2e0e890fa
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "SELECT j.id AS \"id!\", j.created_by AS \"created_by!\",\n CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\\.chat$', '')\n ELSE j.runnable_path END AS runnable_path,\n CASE\n WHEN a.agent THEN 'agent'\n WHEN j.kind IN ('script', 'script_hub', 'unassigned_script', 'preview')\n THEN 'script'\n WHEN j.kind IN ('flow', 'unassigned_flow', 'flowpreview') THEN 'flow'\n WHEN j.kind IN ('singlestepflow', 'unassigned_singlestepflow') THEN\n CASE WHEN COALESCE(\n (SELECT m->'value'->>'type'\n FROM jsonb_array_elements(j.raw_flow->'modules') m\n WHERE m->>'id' IN ('a', 'main')\n LIMIT 1),\n 'script'\n ) = 'flow' THEN 'flow' ELSE 'script' END\n END AS acl_kind\n FROM v2_job j,\n LATERAL (SELECT j.kind = 'flowpreview'\n AND j.raw_flow->'modules'->1 IS NULL\n AND j.raw_flow->'modules'->0->>'id' = '__wm_agent_root' AS agent) a\n WHERE j.id = ANY($1) AND j.workspace_id = $2",
|
||||
"query": "SELECT s.id AS \"id!\", j.created_by AS \"created_by!\",\n CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\\.chat$', '')\n ELSE j.runnable_path END AS runnable_path,\n CASE\n WHEN a.agent THEN 'agent'\n WHEN j.kind IN ('script', 'script_hub', 'unassigned_script', 'preview')\n THEN 'script'\n WHEN j.kind IN ('flow', 'unassigned_flow', 'flowpreview') THEN 'flow'\n WHEN j.kind IN ('singlestepflow', 'unassigned_singlestepflow') THEN\n CASE WHEN COALESCE(\n (SELECT m->'value'->>'type'\n FROM jsonb_array_elements(j.raw_flow->'modules') m\n WHERE m->>'id' IN ('a', 'main')\n LIMIT 1),\n 'script'\n ) = 'flow' THEN 'flow' ELSE 'script' END\n END AS acl_kind\n FROM v2_job s\n JOIN v2_job j ON j.id = COALESCE(s.root_job, s.flow_innermost_root_job, s.parent_job, s.id)\n AND j.workspace_id = s.workspace_id,\n LATERAL (SELECT j.kind = 'flowpreview'\n AND j.raw_flow->'modules'->1 IS NULL\n AND j.raw_flow->'modules'->0->>'id' = '__wm_agent_root' AS agent) a\n WHERE s.id = ANY($1) AND s.workspace_id = $2",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
@@ -37,5 +37,5 @@
|
||||
null
|
||||
]
|
||||
},
|
||||
"hash": "b6644bc0d5ba6063dc70444ec538f87ce996ca4c6203feaf8d42c4e1d42e6cbe"
|
||||
"hash": "a66e2cbe2cef129e4f5b7b633a976d880de6a0cc87278498bea95f9370d3574a"
|
||||
}
|
||||
@@ -2418,13 +2418,14 @@ struct JobRunnable {
|
||||
target: Option<(RunnableAclKind, String)>,
|
||||
}
|
||||
|
||||
/// One query for all `ids`. A saved agent's run is a flow preview under its path (its chat turns
|
||||
/// under `<agent>.chat`), a script or flow wrapped for retries or an error handler a single-step
|
||||
/// flow, and a preview's path the label `require_preview_label_runnable` checks; recognized as
|
||||
/// `require_job_within_read_scope` does.
|
||||
/// One query for all `ids`. A step of a run (a flow's module, a branch, a workflow-as-code child)
|
||||
/// stands for the run it belongs to, as only the top level needs run. A saved agent's run is a
|
||||
/// flow preview under its path (its chat turns under `<agent>.chat`), a script or flow wrapped
|
||||
/// for retries or an error handler a single-step flow, and a preview's path the label
|
||||
/// `require_preview_label_runnable` checks; recognized as `require_job_within_read_scope` does.
|
||||
async fn job_runnables(db: &DB, w_id: &str, ids: &[Uuid]) -> error::Result<Vec<JobRunnable>> {
|
||||
let rows = sqlx::query!(
|
||||
r#"SELECT j.id AS "id!", j.created_by AS "created_by!",
|
||||
r#"SELECT s.id AS "id!", j.created_by AS "created_by!",
|
||||
CASE WHEN a.agent THEN regexp_replace(j.runnable_path, '\.chat$', '')
|
||||
ELSE j.runnable_path END AS runnable_path,
|
||||
CASE
|
||||
@@ -2441,11 +2442,13 @@ async fn job_runnables(db: &DB, w_id: &str, ids: &[Uuid]) -> error::Result<Vec<J
|
||||
'script'
|
||||
) = 'flow' THEN 'flow' ELSE 'script' END
|
||||
END AS acl_kind
|
||||
FROM v2_job j,
|
||||
FROM v2_job s
|
||||
JOIN v2_job j ON j.id = COALESCE(s.root_job, s.flow_innermost_root_job, s.parent_job, s.id)
|
||||
AND j.workspace_id = s.workspace_id,
|
||||
LATERAL (SELECT j.kind = 'flowpreview'
|
||||
AND j.raw_flow->'modules'->1 IS NULL
|
||||
AND j.raw_flow->'modules'->0->>'id' = '__wm_agent_root' AS agent) a
|
||||
WHERE j.id = ANY($1) AND j.workspace_id = $2"#,
|
||||
WHERE s.id = ANY($1) AND s.workspace_id = $2"#,
|
||||
ids,
|
||||
w_id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user