Skip to content

Notifications endpoint accepts negative offset #297

Description

@forgou37

The GET /api/notifications endpoint parses offset without clamping it to a non-negative value.

Repro

GET /api/notifications?offset=-10

Observed:

  • const offset = Number(searchParams.get("offset")) || 0Number("-10") is -10 which is truthy, so the || 0 fallback is skipped
  • offset = -10 is passed to .range(-10, limit - 11), causing a Supabase database error (500)

Fix

Clamp offset to a minimum of 0:

const offset = Math.max(0, Number(searchParams.get("offset")) || 0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions