Skip to content

Prompts list accepts invalid page numbers #298

Description

@forgou37

The GET /api/prompts endpoint parses the page query parameter without clamping it to a valid range — same issue as the directory and other listing endpoints.

Repro

GET /api/prompts?page=-1

Observed:

  • page = parseInt("-1") = -1 (truthy, so || 1 fallback is skipped)
  • offset = (-1 - 1) * 20 = -40
  • Supabase .range(-40, -21) returns a database error (500)

Fix

Clamp page to a minimum of 1:

const page = Math.max(1, parseInt(url.searchParams.get("page") || "1") || 1);

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