nocobase/nocobase · error · Error

node (#${nodeId}) not found in workflow (#${this.execution.w

Error message

node (#${nodeId}) not found in workflow (#${this.execution.workflowId})

What it means

getRerunNode resolves the node to rerun from nodesMap (by id) or by string-comparing ids across the workflow's nodes. If an explicit nodeId is supplied that no node in the execution's workflow matches, it throws rather than rerunning against an unknown node. Called by resolveRerun during processor.rerun.

Source

Thrown at packages/plugins/@nocobase/plugin-workflow/src/server/Processor.ts:380

      await this.prepare();
      const { node, input, targetJob } = this.resolveRerun(options);
      this.rerunContext = {
        overwrite: options.overwrite === true,
        targetJob,
      };

      return await this.run(node, input, { rerun: true });
    } finally {
      this.rerunContext = null;
      this.leaveRunningState();
    }
  }

  private getRerunNode(nodeId?: string | number) {
    if (nodeId != null) {
      const node = this.nodesMap.get(nodeId) || this.nodes.find((item) => String(item.id) === String(nodeId));
      if (!node) {
        throw new Error(`node (#${nodeId}) not found in workflow (#${this.execution.workflowId})`);
      }
      return node;
    }

    const head = this.nodes.find((item) => !item.upstream);
    if (!head) {
      throw new Error(`head node not found in workflow (#${this.execution.workflowId})`);
    }
    return head;
  }

  private getRerunInput(node: FlowNodeModel) {
    if (!node.upstream) {
      return { result: this.execution.context };
    }

    const upstreamJob = this.jobsMapByNodeKey[node.upstream.key];
    if (!upstreamJob) {

View on GitHub (pinned to fa42722fef)

Solutions

  1. Validate the nodeId belongs to execution.workflow.nodes before calling rerun (compare String(node.id) === String(nodeId)).
  2. Pass the numeric node id, not the node key or title.
  3. Refetch the workflow and its nodes to get current ids after edits.
  4. If the node was deleted in a workflow revision, rerun from the head or a still-existing node.

Example fix

// before
await processor.rerun({ nodeId: someKey });
// after
const node = workflow.nodes.find((n) => String(n.id) === String(someKey));
if (!node) {
  throw new Error(`node ${someKey} does not exist in workflow ${workflow.id}`);
}
await processor.rerun({ nodeId: node.id });
Defensive patterns

Strategy: validation

Validate before calling

const nodes = await workflow.getNodes();
const node = nodes.find((n) => String(n.id) === String(nodeId));
if (!node) {
  throw new Error(`node ${nodeId} does not belong to workflow ${workflow.id}`);
}

Type guard

function nodeBelongsToWorkflow(nodes: FlowNodeModel[], nodeId: string | number): node is FlowNodeModel {
  return nodes.some((n) => String(n.id) === String(nodeId));
}

Try / catch

try {
  await processor.rerun({ nodeId });
} catch (e) {
  if (/not found in workflow \(#/.test(e.message)) {
    logger.error(`stale nodeId ${nodeId}; refresh workflow nodes before rerun`);
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: processor.rerun({ nodeId }) where nodeId is not in this.execution.workflow's nodes — id from a different workflow, stale id after the workflow was edited/node deleted, or passing a node key instead of a node id.

Common situations: Rerun requests built from outdated workflow snapshots; passing the key/UUID field where the numeric id is expected; workflow duplicated so ids differ between environments.

Related errors


AI-assisted analysis of nocobase/nocobase@fa42722fef (2026-09-01). Data as JSON: /api/errors/2e6c14f9f02c83df. Report an issue: GitHub.