nocobase/nocobase · error · Error
job of head node (#${node.id}) not found in execution (#${th
Error message
job of head node (#${node.id}) not found in execution (#${this.execution.id}) What it means
This is the head-node variant of the rerun check: when rerun is called without nodeId but with overwrite=true, resolveRerun requires an existing job for the workflow's head node, because overwriting a rerun must replace an existing prior result. If the head node has no job recorded, it throws.
Source
Thrown at packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts:341
try {
await this.prepare();
const node: FlowNodeModel = this.nodesMap.get(job.nodeId) as FlowNodeModel;
await this.recall(node, job);
} finally {
this.leaveRunningState();
}
}
private resolveRerun(options: ProcessorRerunOptions = {}) {
const node = this.getRerunNode(options.nodeId);
const targetJob = this.jobsMapByNodeKey[node.key];
if (options.nodeId != null && !targetJob) {
throw new Error(`job of node (#${node.id}) not found in execution (#${this.execution.id})`);
}
if (options.nodeId == null && options.overwrite && !targetJob) {
throw new Error(`job of head node (#${node.id}) not found in execution (#${this.execution.id})`);
}
const input = this.getRerunInput(node);
return { node, input, targetJob };
}
public async rerun(options: ProcessorRerunOptions = {}) {
const { execution } = this;
if (execution.status !== EXECUTION_STATUS.STARTED) {
throw new Error(`execution (#${execution.id}) is not started`);
}
if (!(await this.shouldContinueExecution())) {
this.logger.warn(`execution was ended with status ${execution.status} before, could not be rerun`, {
workflowId: execution.workflowId,
});
return;
}
View on GitHub (pinned to fa42722fef)
Solutions
- Wait until the execution has at least run its head node before calling rerun with overwrite: true.
- Call rerun() without overwrite (append mode) if you don't need to replace prior results.
- If jobs were purged, re-trigger the workflow to create a new execution instead of rerunning.
- Confirm the head node (node without upstream) matches the node that produced the job.
Example fix
// before
await processor.rerun({ overwrite: true }); // throws if nothing ran yet
// after
const head = execution.workflow.nodes.find((n) => !n.upstream);
const hasJob = await execution.countJobs({ where: { nodeId: head.id } });
await processor.rerun({ overwrite: hasJob > 0 }); Defensive patterns
Strategy: validation
Validate before calling
const head = workflow.nodes.find((n) => !n.upstream);
const headJob = head && (await execution.countJobs({ where: { nodeId: head.id } }));
if (overwrite && !headJob) {
throw new Error('cannot overwrite-rerun: head node has not executed in this execution yet');
} Type guard
function canOverwriteRerun(execution: ExecutionModel, workflow: WorkflowModel): boolean {
const head = (workflow.nodes ?? []).find((n) => !n.upstream);
return !!head && Array.isArray(execution.jobs) && execution.jobs.some((j) => j.nodeId === head.id);
} Try / catch
try {
await processor.rerun({ overwrite: true });
} catch (e) {
if (/job of head node/.test(e.message)) {
logger.warn('nothing executed yet; running append-mode rerun instead');
await processor.rerun({});
return;
}
throw e;
} Prevention
- Use overwrite: true only on executions with prior successful node runs.
- Debounce/deduplicate rerun button clicks so a completed rerun isn't re-invoked.
- Check execution status and job count before choosing overwrite mode.
- Avoid editing the workflow head node while executions are pending rerun.
When it happens
Trigger: processor.rerun({ overwrite: true }) on an execution whose head node never produced a job — e.g. the execution started but failed before the head node executed, jobs were deleted, or the first node's key changed so jobsMapByNodeKey lookup misses.
Common situations: Overwrite-rerun of a freshly created execution that has not executed any node yet; rerun after job cleanup jobs purged the head job; workflow edited so the current head node differs from the one that ran.
Related errors
- job of node (#${node.id}) not found in execution (#${this.ex
- upstream job of node (#${node.id}) not found in execution (#
- workflow (#${execution.workflowId}) not found for execution
- execution (#${execution.id}) is not started
- node (#${nodeId}) not found in workflow (#${this.execution.w
AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01).
Data as JSON: /api/errors/525a72aebd94a21b.
Report an issue: GitHub.