Significant-Gravitas/AutoGPT · error · Error

n8n template not found (${res.status})

Error message

n8n template not found (${res.status})

What it means

Thrown by fetchN8nWorkflow when the n8n templates API (N8N_TEMPLATES_API hardcoded base) answers the GET {base}/{numericId} with a non-ok status. The templateId has already been sanitized via parseInt round-trip, so this is purely a server-side outcome: 404 (no such template), 429/403 (rate-limited/blocked), or 5xx on n8n's side. The status code is embedded in the message.

Source

Thrown at autogpt_platform/frontend/src/app/(platform)/library/components/LibraryImportDialog/components/ExternalWorkflowTab/fetchWorkflowFromUrl.ts:69

    return { ok: true, json };
  } catch (err) {
    return {
      ok: false,
      error: err instanceof Error ? err.message : "Failed to fetch workflow.",
    };
  }
}

async function fetchN8nWorkflow(templateId: string): Promise<string> {
  // Only ever fetch from the hardcoded API base + numeric ID.
  // parseInt + toString round-trips to guarantee the value is purely numeric,
  // preventing any path-traversal or SSRF via the interpolated segment.
  const safeId = parseInt(templateId, 10);
  if (!Number.isFinite(safeId) || safeId <= 0) {
    throw new Error("Invalid template ID");
  }
  const res = await fetch(`${N8N_TEMPLATES_API}/${safeId.toString()}`);
  if (!res.ok) throw new Error(`n8n template not found (${res.status})`);

  const contentLength = res.headers.get("content-length");
  if (contentLength && parseInt(contentLength, 10) > MAX_RESPONSE_BYTES) {
    throw new Error("Response too large.");
  }

  const text = await res.text();
  if (text.length > MAX_RESPONSE_BYTES) throw new Error("Response too large.");

  const data = JSON.parse(text);
  const template = data?.workflow ?? data;
  const workflow = template?.workflow ?? template;
  if (!workflow?.nodes) throw new Error("Unexpected n8n API response format");
  if (!workflow.name) workflow.name = template?.name ?? data?.name ?? "";
  return JSON.stringify(workflow);
}

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Read the embedded status: 404 means the template ID is wrong or gone — verify by opening the URL directly in a browser.
  2. 429 → wait and retry; the fetch has no backoff, so clicking Import again after a minute usually works.
  3. 5xx → n8n-side outage; retry later or export the workflow JSON from n8n and use the file-import path instead.
  4. Confirm the pasted URL is actually a template URL (numeric ID), not a workflow URL from an n8n instance (those aren't fetchable here).
Defensive patterns

Strategy: retry

Validate before calling

function extractTemplateId(url: string): number | null {
  const m = url.match(/templates\/(\d+)/);
  const id = m ? parseInt(m[1], 10) : NaN;
  return Number.isFinite(id) && id > 0 ? id : null;
}

Type guard

function isN8nNotFound(err: unknown): boolean {
  return err instanceof Error && err.message.startsWith("n8n template not found");
}

Try / catch

try {
  const wf = await fetchN8nWorkflow(id);
} catch (error) {
  if (isN8nNotFound(error)) {
    const status = Number(error.message.match(/\((\d+)\)/)?.[1]);
    if (status === 429 || status >= 500) { /* retry with backoff */ }
    else toast({ description: "That template doesn't exist or was removed." });
  }
}

Prevention

When it happens

Trigger: User pastes an n8n template URL whose numeric ID doesn't exist (typo, removed template) → 404; the platform hammers the n8n API and gets rate-limited → 429; n8n API outage → 5xx.

Common situations: Importing from an old bookmarked n8n template link whose template was unpublished; shared dev environments hitting n8n rate limits; corporate egress proxies blocking api.n8n.io.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/2c589e83fb8fef6c. Report an issue: GitHub.