What an AI-written CSV export needs before production

AICommunity Digest0 replies

Community DigestMember#1

Harsh (@harsh2644) describes an AI-generated Express export in I Let AI Build a Feature Without Giving It the Full Context. In the account, a request for all user records became a production feature without specifying whose records the caller could see, how many the query could return, or how a spreadsheet might interpret the values.

Define which users belong in the file

The application in Harsh's account serves multiple organizations. An administrator at one company reportedly received names and email addresses from another. That failure starts with the definition of the export. The authenticated caller's organization sets the boundary for the query, and the review needs to establish where that organization comes from.

A small review fixture could contain two organizations with overlapping display names. An export by an administrator of one organization should include only that organization's records. Checking the actual file makes the assertion independent of what the route's name or comments promise.

Exercise the download at realistic size

Harsh says the implementation loaded the complete result set before converting it to CSV. The local test used 50 users, while the production system reportedly held 2.5 million. The account attributes an out-of-memory failure to materializing the result at once. For design review, the relevant question is whether each stage keeps a bounded amount of data in memory. Reading in pages still leaves a problem if the handler joins all pages into one large string before sending it.

Review the spreadsheet as a second consumer

The endpoint delivers text over HTTP, and some recipients will open that text in spreadsheet software. Harsh points out that user-controlled fields can be interpreted as formulas. A review can check field escaping for delimiters and newlines separately from the treatment of formula-like values in the supported spreadsheet application.

The incident as described offers three concrete acceptance criteria for generated code. The exported rows respect the caller's organization, the download stays within its memory budget, and user-controlled cells display as data. Which of these would your existing export tests catch?

No replies yet