diegosouzapw/OmniRoute · error

PAYLOAD_TOO_LARGE

PAYLOAD_TOO_LARGE

Error message

Request body too large. Maximum allowed: ${formatBytes(limit)}

What it means

Error "Request body too large. Maximum allowed: ${formatBytes(limit)}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/shared/middleware/bodySizeGuard.ts:108

  return customRule.fixedLimit ? customRule.limit : Math.max(customRule.limit, configuredLimit);
}

/**
 * Check Content-Length header against the configured limit.
 * Returns a 413 Response if the body is too large, or null if OK.
 */
export function checkBodySize(request: Request, limit: number = MAX_BODY_BYTES): Response | null {
  const contentLength = request.headers.get("content-length");

  if (contentLength) {
    const bytes = Number.parseInt(contentLength, 10);
    if (!Number.isNaN(bytes) && bytes > limit) {
      return new Response(
        JSON.stringify({
          error: {
            message: `Request body too large. Maximum allowed: ${formatBytes(limit)}`,
            type: "payload_too_large",
            code: "PAYLOAD_TOO_LARGE",
          },
        }),
        {
          status: 413,
          headers: {
            "Content-Type": "application/json",
          },
        }
      );
    }
  }

  return null;
}

export class RequestBodyTooLargeError extends Error {
  constructor(readonly limit: number) {
    super(`Request body exceeds ${formatBytes(limit)}`);

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/shared/middleware/bodySizeGuard.ts:108 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/334ea058d49c00c8. Report an issue: GitHub.