{"record":{"id":"d229748afe50188e","repo":"windmill-labs/windmill","slug":"job-has-no-parent-flow","errorCode":null,"errorMessage":"job {} has no parent flow","messagePattern":"job (.+?) has no parent flow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-api/src/jobs.rs","lineNumber":6082,"sourceCode":"        SELECT kind::text as \"kind!\", parent_job\n        FROM v2_job\n        WHERE id = $1\n        \"#,\n        job_id\n    )\n    .fetch_optional(db)\n    .await?\n    .ok_or_else(|| anyhow::anyhow!(\"job not found: {}\", job_id))?;\n\n    // If it's a flow job, return the job_id itself\n    if job_info.kind == \"flow\" || job_info.kind == \"flowpreview\" {\n        return Ok(job_id);\n    }\n\n    // Otherwise, return the parent flow ID\n    job_info\n        .parent_job\n        .ok_or_else(|| anyhow::anyhow!(\"job {} has no parent flow\", job_id).into())\n}\n\n#[derive(Deserialize)]\nstruct CancelJob {\n    reason: Option<String>,\n}\n\n#[derive(Debug, Deserialize)]\n#[serde(rename_all = \"lowercase\")]\nenum PreviewKind {\n    Code,\n    Identity,\n    Noop,\n    Bundle,\n    Tarbundle,\n    ScriptHash,\n}\n","sourceCodeStart":6064,"sourceCodeEnd":6100,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-api/src/jobs.rs#L6064-L6100","documentation":"The jobs API looked up a job that is expected to be part of a flow run, but the stored job row has no parent_job (parent flow) reference. The endpoint needs the enclosing flow's job ID (e.g. to resolve flow-level context or act on the flow) and throws when the job is standalone. This typically means the caller passed a job ID that is not a flow child — it is a top-level script/flow run.","triggerScenarios":"Calling jobs.rs:6082's helper (resolving a job's parent flow ID) with a job_id whose `job_info.parent_job` is NULL — i.e. a standalone script run, a flow run itself (root), or a job created outside a flow context.","commonSituations":"Passing the flow run's own job ID instead of a child step's job ID; passing a standalone script job ID to an endpoint that only accepts flow-child jobs; job rows created by older/legacy code paths that never set parent_job; cancelled or cleaned-up jobs whose parent linkage was removed.","solutions":["Verify the job_id you pass belongs to a child step inside a flow run (check job row's parent_job in the database: SELECT parent_job FROM job WHERE id = <job_id>).","If you have the flow run's ID, use it directly instead of trying to resolve a parent from a child.","For standalone script jobs, use the job-specific endpoints rather than the flow-scoped one.","If the job should have a parent but does not, check whether it was created via the raw job-creation path instead of the flow executor."],"exampleFix":"// before\nlet parent = get_parent_flow_id(standalone_job_id).await?; // Err: job X has no parent flow\n// after\nlet job = get_job(job_id).await?;\nlet parent = match job.parent_job {\n    Some(pid) => pid,\n    None => job.id, // it's a root/standalone job; act on it directly\n};","handlingStrategy":"type-guard","validationCode":"const job = await client.getJob(jobId);\nif (!job.parent_job) throw new Error(`job ${jobId} is standalone; use flow-specific APIs only with child jobs`);","typeGuard":"function hasParentFlow(job) { return typeof job.parent_job === 'string' && job.parent_job.length > 0; }","tryCatchPattern":"try {\n  const flowId = await resolveParentFlow(jobId);\n} catch (e) {\n  if (String(e).includes('has no parent flow')) {\n    // treat job as root: operate on jobId itself\n  } else throw e;\n}","preventionTips":["Only pass child-step job IDs to flow-scoped endpoints","Check parent_job before resolving","Keep the job ID of the flow run alongside child IDs in your tooling"],"tags":["jobs","flow","backend","missing-parent"],"backgroundTag":"job-has-no-parent-flow","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}