ADR 0165: A suggestion's stored details are held to a bound below the column's check, measured as Postgres measures them
- Status: Accepted
- Date: 2026-10-26
- Decision issue: #227
- Parent story: #204
- Parent epic: #16
- Builds on: ADR 0153, ADR 0154
Context#
The submission is bounded at 12 KiB as sent, and details has a check of octet_length(details::text) <= 16384. A link is stored percent-encoded and re-written, so a CJK address of three bytes a
character is nine bytes stored, and Postgres writes jsonb text with a space after every : and ,.
A suggestion that passed the 12 KiB check could therefore exceed 16 KiB when stored and fail its
insert, every time, with a 502.
Decision#
- A submission whose stored
detailswould exceed 11 KiB is refused withtooLarge, by bothSubmission::from_jsonand the browser'sreadSuggestionSubmissionJson, at the same point, so the form says it is too long and the function stores nothing. The size is measured as Postgres measuresdetails::text: the compact JSON plus one byte for every:and,outside a string, of exactly{type, url?, hints?, about?, contact?}. 11 KiB leaves the room eight links need at their widest (ADR 0162), and a test sums them. - A shared fixture case (links of three-byte characters that percent-encoding makes too large
for the stored row) holds both sides to it;
tests/fixtures/future-suggestion-submissions.jsonis regenerated by the Rust side. - The whole stored record is read under 32 KiB, not 16 KiB. A record is the text (the row's
body, at most 8,000 bytes),details(under its own 16 KiB check) and the name, receipt and revision (about 1.5 KiB), so a text of four-byte characters with links at the details bound made a record of 18.5 KiB that was stored and then refused on reading. The columns already bound each part;MAX_JSON_BYTESis now their sum with room to spare, one limit, so every accepted submission still reads back after eight links and a clarification. A shared fixture case and a test with eight widest links and a clarification hold it.