Significant-Gravitas/AutoGPT · warning · Error
Response too large.
Error message
Response too large.
What it means
First of two size guards in fetchN8nWorkflow: before reading the body, it checks the Content-Length response header against MAX_RESPONSE_BYTES and throws 'Response too large.' if the declared size exceeds the cap. This prevents buffering multi-megabyte template payloads. Because Content-Length is optional (absent on chunked/streamed responses), this guard only fires when the server declares a size — the second guard (error 27) covers the rest.
Source
Thrown at autogpt_platform/frontend/src/app/(platform)/library/components/LibraryImportDialog/components/ExternalWorkflowTab/fetchWorkflowFromUrl.ts:73
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
- Pick a smaller template — this is a client-side protective cap, and the template genuinely exceeds it.
- If you need the template, open it on n8n.io, export the workflow JSON manually, and use the file import path instead of the URL fetch.
- Self-hosters can raise MAX_RESPONSE_BYTES in the module if they accept the memory cost.
- Check n8n API changes if ALL templates suddenly trip the guard (response envelope grew).
Defensive patterns
Strategy: validation
Validate before calling
function withinSizeCap(contentLength: string | null, cap: number): boolean {
if (!contentLength) return true; // unknown yet, second guard will decide
const n = parseInt(contentLength, 10);
return Number.isFinite(n) && n <= cap;
} Type guard
function isResponseTooLarge(err: unknown): boolean {
return err instanceof Error && err.message === "Response too large.";
} Try / catch
try {
await importFromN8nUrl(url);
} catch (error) {
if (isResponseTooLarge(error)) {
toast({ description: "This template is too large to import automatically — download its JSON and use file import." });
}
} Prevention
- Always check Content-Length before res.text() when fetching third-party JSON — this code is the pattern to copy.
- Keep the file-import path available as the escape hatch for oversized templates.
- Don't raise MAX_RESPONSE_BYTES without considering client memory (res.text() buffers the whole body).
When it happens
Trigger: GET to the n8n templates API returning Content-Length > MAX_RESPONSE_BYTES for a template with an unusually large workflow JSON (thousands of nodes, embedded base64 assets).
Common situations: Importing a community mega-template; n8n API changing response format (wrapping templates with extra payload) pushing sizes over the cap; MAX_RESPONSE_BYTES tuned down locally.
Related errors
- n8n template not found (${res.status})
- Unexpected n8n API response format
- Authentication failed — please sign in again.
- Failed to fetch session (status: ${response.status})
- Invalid form
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/537d813cbcf3071e.
Report an issue: GitHub.