{"record":{"id":"334ea058d49c00c8","repo":"diegosouzapw/OmniRoute","slug":"payload-too-large","errorCode":"PAYLOAD_TOO_LARGE","errorMessage":"Request body too large. Maximum allowed: ${formatBytes(limit)}","messagePattern":"Request body too large\\. Maximum allowed: (.+?)","errorType":"http","errorClass":null,"httpStatus":413,"severity":"error","filePath":"src/shared/middleware/bodySizeGuard.ts","lineNumber":108,"sourceCode":"  return customRule.fixedLimit ? customRule.limit : Math.max(customRule.limit, configuredLimit);\n}\n\n/**\n * Check Content-Length header against the configured limit.\n * Returns a 413 Response if the body is too large, or null if OK.\n */\nexport function checkBodySize(request: Request, limit: number = MAX_BODY_BYTES): Response | null {\n  const contentLength = request.headers.get(\"content-length\");\n\n  if (contentLength) {\n    const bytes = Number.parseInt(contentLength, 10);\n    if (!Number.isNaN(bytes) && bytes > limit) {\n      return new Response(\n        JSON.stringify({\n          error: {\n            message: `Request body too large. Maximum allowed: ${formatBytes(limit)}`,\n            type: \"payload_too_large\",\n            code: \"PAYLOAD_TOO_LARGE\",\n          },\n        }),\n        {\n          status: 413,\n          headers: {\n            \"Content-Type\": \"application/json\",\n          },\n        }\n      );\n    }\n  }\n\n  return null;\n}\n\nexport class RequestBodyTooLargeError extends Error {\n  constructor(readonly limit: number) {\n    super(`Request body exceeds ${formatBytes(limit)}`);","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/shared/middleware/bodySizeGuard.ts#L90-L126","documentation":"Error \"Request body too large. Maximum allowed: ${formatBytes(limit)}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/shared/middleware/bodySizeGuard.ts:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}