Skip to content

[Backend] Negative offset/page returns 500 (Prisma) instead of 400 on list endpoints #811

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

stream.controller.ts:181 (Number.parseInt(offset,10) || 0) and :297-298, plus user.controller.ts:88, keep a negative parsed value (-5 is truthy, so || 0 does not replace it) and pass it straight to Prisma skip. Prisma rejects a negative skip with a validation error, returned as 500. So GET /v1/streams?offset=-1 and the events endpoints all 500. The correct guard already exists in events.routes.ts:96.

Acceptance criteria

  • Negative offset/page on the listing endpoints returns 400 or is clamped to 0
  • Apply the same >= 0 clamp used in events.routes.ts:96 to listStreams, getStreamEvents and getUserEvents
  • Add a test asserting a negative offset no longer yields 500

Files to touch

  • backend/src/controllers/stream.controller.ts
  • backend/src/controllers/user.controller.ts

Out of scope

  • Cursor-based pagination changes

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions