akash-network / akash-network/console
perf(api): add body size validation to notification/alert proxy routes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 264
- Forks
- 94
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 297
Description
Problem
The notification and alert proxy routes forward request bodies as-is to the downstream notifications service without any size validation.
// proxy.route.ts
await req.text() // reads full body without size check, then forwards it
These routes accept POST, PATCH, and DELETE methods and proxy the full body content.
Affected Routes
POST /v1/notification-channels/*PATCH /v1/notification-channels/*DELETE /v1/notification-channels/*POST /v1/alertsPATCH /v1/alertsDELETE /v1/alerts
Suggested Fix
Add body size validation before proxying:
const body = await req.text();
if (body.length > MAX_PROXY_BODY_SIZE) {
return c.json({ error: "Request body too large" }, 413);
}
Or apply the global body limit middleware (from #2582) which would cover these routes automatically.
Files
apps/api/src/notifications/routes/proxy.route.ts
Context
Part of the API event loop performance audit.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apps/api/src/notifications/routes/proxy.route.ts and inspect how the notification-channel and alert proxy routes read and forward request bodies. Compare the proposed local check with the global body limit middleware from #2582. Done means the affected POST, PATCH, and DELETE routes reject oversized bodies with status 413 while continuing to proxy acceptable bodies.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100