Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: API request content-length is limit to 100KB #6449

Open
2 tasks done
hunghvu opened this issue Sep 5, 2024 · 1 comment
Open
2 tasks done

🐛 Bug Report: API request content-length is limit to 100KB #6449

hunghvu opened this issue Sep 5, 2024 · 1 comment
Labels

Comments

@hunghvu
Copy link

hunghvu commented Sep 5, 2024

📜 Description

Right now, Novu API can only accept request size 100 KB at most. A simple trigger event is around 70 KB, but with attachments, it can easily exceed 100 KB, leading to code 413 Payload too large.

Not a NestJS expert, but I think the code below does not initialize Nest App with correct bodyParser and rawBody configuration, leading to an unexpected behavior.

bodyParser: false,

Quick NestJS reference: https://docs.nestjs.com/faq/raw-body#body-parser-size-limit

👟 Reproduction steps

Use a simple trigger event with attachments.

await novu.trigger("workflow-id", {
  to: "subscriber-id",
  payload: {
    // Practically total file size is limit around 30 KB, because the request itself is around 70 KB.
    attachments: [bufferData] 
  }
}) 

👍 Expected behavior

There are 2 possible ways.

  1. Allow a safe, fixed limit for an API request size.
  2. Expose a configuration (e.g., via environment variable), so developers can customize limits on their own. Why? Each notification/message provider has their own size limit, so developers can set the limit at their own judgment. For example, Gmail is capped at 25 MB per request.

👎 Actual Behavior with Screenshots

Here is a sample error emitted by Novu API service.

{
    "level": 50,
    "time": 1725558183913,
    "pid": 18,
    "serviceName": "@novu/api",
    "serviceVersion": "0.24.0",
    "platform": "Docker",
    "tenant": "OS",
    "context": "ExceptionsHandler",
    "err": {
        "type": "Error",
        "message": "request entity too large",
        "stack": "PayloadTooLargeError: request entity too large\n    
        at readStream (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:163:17)\n    
        at getRawBody (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/raw-body/index.js:116:12)\n    
        at read (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/read.js:79:3)\n    
        at jsonParser (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/body-parser/lib/types/json.js:138:5)\n    
        at Layer.handle [as handle_request] (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)\n    
        at trim_prefix (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)\n    
        at /usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9\n    
        at Function.process_params (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)\n    
        at next (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)\n    
        at initialize (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/passport/lib/middleware/initialize.js:98:5)\n    
        at Layer.handle [as handle_request] (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)\n    
        at trim_prefix (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:328:13)\n    
        at /usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:286:9\n    
        at Function.process_params (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:346:12)\n    
        at next (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/index.js:280:10)\n    
        at cors (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/cors/lib/index.js:188:7)"
    },
    "msg": "request entity too large"
}

Novu version

Self-host, Docker, v0.24.0

npm version

NA (using the official v0.24.0 images)

node version

NA (using the official v0.24.0 images)

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant