diegosouzapw/OmniRoute · error

BODY_TOO_LARGE

Error message

BODY_TOO_LARGE

What it means

Error "BODY_TOO_LARGE" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/app/api/providers/command-code/auth/shared.ts:100

    status: 403,
    headers: callbackCorsHeaders(request),
  });
}

export async function readJsonBodyWithLimit(request: Request, maxBytes: number): Promise<unknown> {
  const reader = request.body?.getReader();
  if (!reader) return request.json();

  const chunks: Uint8Array[] = [];
  let total = 0;
  while (true) {
    const { value, done } = await reader.read();
    if (done) break;
    if (!value) continue;
    total += value.byteLength;
    if (total > maxBytes) {
      await reader.cancel();
      throw new Error("BODY_TOO_LARGE");
    }
    chunks.push(value);
  }

  const body = new TextDecoder().decode(Buffer.concat(chunks));
  return JSON.parse(body);
}

export function buildCommandCodeCliCallbackUrl(): string {
  const configuredPort = process.env.COMMAND_CODE_CALLBACK_PORT || "";
  const port = /^\d+$/.test(configuredPort)
    ? Number.parseInt(configuredPort, 10)
    : COMMAND_CODE_CLI_CALLBACK_PORTS[0];
  const safePort = COMMAND_CODE_CLI_CALLBACK_PORTS.includes(
    port as (typeof COMMAND_CODE_CLI_CALLBACK_PORTS)[number]
  )
    ? port
    : COMMAND_CODE_CLI_CALLBACK_PORTS[0];

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/app/api/providers/command-code/auth/shared.ts:100 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/bc7b78c6407eb223. Report an issue: GitHub.