flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[API] Limit embedded events in GET /v1/streams/:streamId

Open blurbeast opened this issue 2 weeks ago • 5 comments

Overview & Background

GET /v1/streams/:streamId embeds every event row with no limit: include: { ... events: { orderBy: { timestamp: "desc" } } } — no take. The dedicated events endpoint paginates at max 200 (MAX_EVENTS_PAGE_SIZE), but the single-stream response returns the entire event history. A long-lived stream with tens of thousands of events produces unbounded memory/serialization, and the endpoint is unauthenticated — a trivially abusable amplification.


Technical Specification & Architecture

  1. Add a small take (e.g. latest 20) to the embedded events relation in backend/src/controllers/stream.controller.ts:289-298.
  2. Point clients at GET /:streamId/events (already paginated) for full history.
  3. Document the embedded-events limit in the OpenAPI spec generated by codegen:openapi.

Target Files

  • backend/src/controllers/stream.controller.ts
  • OpenAPI codegen inputs

Acceptance Criteria

  • [ ] Embedded events are capped at a documented count.
  • [ ] Response size for a stream with 50k events is bounded.
  • [ ] Full history remains reachable via the paginated events endpoint.

blurbeast avatar Nov 18 '26 19:11 blurbeast

@Babanla0011 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

please assign, i will submit PR now

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Babanla0011 to this issue.

Babanla0011 avatar Nov 21 '26 08:11 Babanla0011

@edrizxabdulganiyu-blip has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

Hello Maintainer, I've reviewed the issue description and I'm confident I can work on it effectively. Please assign it to me.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @edrizxabdulganiyu-blip to this issue.

edrizxabdulganiyu-blip avatar Nov 21 '26 08:11 edrizxabdulganiyu-blip

@simplex001 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

i can resolve

ℹ️ Repo Maintainers: To accept this application, review their application or assign @simplex001 to this issue.

simplex001 avatar Nov 21 '26 08:11 simplex001

Congratulations, @simplex001! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

🧑‍💻 @simplex001: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Nov 21 '26 08:11 drips-wave[bot]

This issue has been completed by @simplex001 as part of the Stellar Wave Program's 11th Wave 🥳

😎 @simplex001: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Nov 22 '26 20:11 drips-wave[bot]