Skip to content

Bug: chat message pagination accepts malformed limit and offset values #113

Description

@rissrice2105-agent

Summary

GET /api/chat/messages parses the limit and offset query params directly with parseInt and passes the results into the Supabase range call. Malformed values such as limit=abc can become NaN, partially numeric values such as limit=1abc are accepted as 1, and negative offsets can build negative ranges.

Impact

Invalid pagination input can produce unexpected message windows or database range errors instead of falling back to safe defaults.

Steps to reproduce

  1. Authenticate and request /api/chat/messages?conversation_id=&limit=abc&offset=-5
  2. The route computes invalid pagination values and passes them into .range(offset, offset + limit - 1).

Expected

The API should use safe pagination defaults for malformed values, clamp excessive limits, and never pass negative or NaN values into the database range.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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