windmill-labs/windmill · error

Could not fetch the run this recording is based on

Error message

Could not fetch the run this recording is based on

What it means

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.

Source

Thrown at frontend/src/lib/components/recording/runRecording.ts:133

			jobs[job.id] = job
			next.push(...directSubJobIds(job.flow_status))
		}
		frontier = next
	}
	return jobs
}

/** Build a flow recording from a completed run. */
export async function buildFlowRecording(
	workspace: string,
	rootJobId: string,
	flowPath: string,
	flow?: OpenFlow
): Promise<FlowRecording> {
	const jobs = await fetchRunJobs(workspace, rootJobId)
	const root = jobs[rootJobId]
	if (!root) {
		throw new Error('Could not fetch the run this recording is based on')
	}
	return {
		version: 2,
		type: 'flow',
		recorded_at: new Date().toISOString(),
		flow_path: flowPath,
		total_duration_ms: (root as any).duration_ms ?? 0,
		root_job_id: rootJobId,
		jobs,
		// JSON round-trip to strip non-serializable properties (event handlers, …)
		flow: flow ? (JSON.parse(JSON.stringify(flow)) as OpenFlow) : undefined
	}
}

/** Build a script recording from a completed test run. Code/schema are passed
 * in as they were at run time — a preview job doesn't carry the schema and its
 * code may since have been edited. `args` defaults to the job's own. */
export async function buildScriptRecording(

View on GitHub (pinned to e474e8803c)

Solutions

  1. Verify rootJobId exists in the target workspace (check via the runs page or API)
  2. Re-record against an existing, accessible run
  3. Confirm the workspace argument matches the run's workspace and the user has read access
Defensive patterns

Strategy: validation

Validate before calling

const jobs = await fetchRunJobs(workspace, rootJobId)
if (!jobs?.[rootJobId]) return null // skip recording creation

Type guard

function hasRootJob(jobs: Record<string, unknown>, id: string): boolean { return Boolean(jobs?.[id]) }

Try / catch

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 }

Prevention

When it happens

Trigger: Calling buildFlowRecording/buildFlowRecordingFromRun for a rootJobId whose job record is absent from fetchRunJobs' result — deleted run, wrong workspace, or restricted permissions.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/e75bebd7727abf76. Report an issue: GitHub.