Skip to content

CSV export silently truncates at 1000 cases with no pagination #54

Description

@royalpinto007

app/api/export/route.ts is the machine-readable view of the registry, and it silently truncates:

.eq("status", "approved")
.order("vote_score", { ascending: false })
.limit(1000);

Once the registry passes 1000 approved cases, /api/export returns the 1000 highest-voted ones and says nothing about the rest. A consumer building a dataset has no way to detect that they got a partial answer, and because the ordering is by vote_score the truncation is also biased toward popular cases rather than being a clean prefix.

There are related rough edges in the same handler worth doing at the same time:

  • No pagination parameters at all, so there is no way to ask for the remainder.
  • No Content-Disposition header, so the CSV renders in the browser rather than downloading.
  • No documented schema. The headers array in this file is the only description of the columns that exists anywhere.

Suggested shape:

  • Accept ?limit= and ?offset= (or a cursor on case_number) with a sane maximum, validated with Zod the way the other routes validate input.
  • Return a header or a trailing metadata row indicating the total count so truncation is detectable.
  • Add Content-Disposition: attachment; filename="agentpostmortem-export.csv".
  • Document the columns in the README next to the rest of the registry description.

Note that #20 covers CSV formula injection in the same file. Keep the two changes separate so they review independently.

If you would like to take this on, comment here to claim it. Contributors can hold two open claims at a time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions