{"record":{"id":"e75bebd7727abf76","repo":"windmill-labs/windmill","slug":"could-not-fetch-the-run-this-recording-is-based-on","errorCode":null,"errorMessage":"Could not fetch the run this recording is based on","messagePattern":"Could not fetch the run this recording is based on","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/recording/runRecording.ts","lineNumber":133,"sourceCode":"\t\t\tjobs[job.id] = job\n\t\t\tnext.push(...directSubJobIds(job.flow_status))\n\t\t}\n\t\tfrontier = next\n\t}\n\treturn jobs\n}\n\n/** Build a flow recording from a completed run. */\nexport async function buildFlowRecording(\n\tworkspace: string,\n\trootJobId: string,\n\tflowPath: string,\n\tflow?: OpenFlow\n): Promise<FlowRecording> {\n\tconst jobs = await fetchRunJobs(workspace, rootJobId)\n\tconst root = jobs[rootJobId]\n\tif (!root) {\n\t\tthrow new Error('Could not fetch the run this recording is based on')\n\t}\n\treturn {\n\t\tversion: 2,\n\t\ttype: 'flow',\n\t\trecorded_at: new Date().toISOString(),\n\t\tflow_path: flowPath,\n\t\ttotal_duration_ms: (root as any).duration_ms ?? 0,\n\t\troot_job_id: rootJobId,\n\t\tjobs,\n\t\t// JSON round-trip to strip non-serializable properties (event handlers, …)\n\t\tflow: flow ? (JSON.parse(JSON.stringify(flow)) as OpenFlow) : undefined\n\t}\n}\n\n/** Build a script recording from a completed test run. Code/schema are passed\n * in as they were at run time — a preview job doesn't carry the schema and its\n * code may since have been edited. `args` defaults to the job's own. */\nexport async function buildScriptRecording(","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/recording/runRecording.ts#L115-L151","documentation":"buildFlowRecording fetches all jobs of the root run (fetchRunJobs) and needs the root job record to describe the flow recording. If the jobs map has no entry for rootJobId, the run data could not be retrieved and it throws.","triggerScenarios":"Calling buildFlowRecording/buildFlowRecordingFromRun for a rootJobId whose job record is absent from fetchRunJobs' result — deleted run, wrong workspace, or restricted permissions.","commonSituations":"Creating a recording for a run that was purged by retention/cleanup; using a job id from a different workspace; API returning a partial/empty jobs map due to permission filtering.","solutions":["Verify rootJobId exists in the target workspace (check via the runs page or API)","Re-record against an existing, accessible run","Confirm the workspace argument matches the run's workspace and the user has read access"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const jobs = await fetchRunJobs(workspace, rootJobId)\nif (!jobs?.[rootJobId]) return null // skip recording creation","typeGuard":"function hasRootJob(jobs: Record<string, unknown>, id: string): boolean { return Boolean(jobs?.[id]) }","tryCatchPattern":"try { rec = await buildFlowRecording(workspace, rootJobId, flowPath) } catch (e) { if (/Could not fetch the run/.test(String(e))) notify('Run not found or inaccessible'); else throw e }","preventionTips":["Verify the run exists and is accessible before building a recording from it","Keep recordings pointing at runs within retention windows","Pass the correct workspace for the run"],"tags":["recording","flow","api","missing-data"],"backgroundTag":"resource-not-found","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"}