Repository navigation
fix(databases): return 400 when a row is too large for its index - #14374
Conversation
Row create, update and upsert, single and bulk, did not catch the database Limit exception, so a value over the Postgres B-tree index row size limit surfaced as a 500. Map it to the attribute/column limit error, as the transaction commit and increment/decrement already do.
|
Review complete. No issues found — approved ✅. This change maps the database layer's row-too-large-for-index limit exception to a client-facing 400 error on all document write paths: create, update, upsert, and their bulk variants. Each endpoint now catches the limit exception via the existing
Reviewed commit: 6cef02c |
🟢 Tier S · Ready to mergeThe row and document create, update, and upsert handlers translate database limit exceptions into the API-specific 400 error for single and bulk writes. The new PostgreSQL E2E regression creates an indexed string field with a value exceeding the B-tree limit and checks all six write paths. Latest changes: The latest commit adds a PostgreSQL E2E regression covering single and bulk create, update, and upsert responses for oversized indexed values.
📂 Walkthrough · 6
✅ Fixed since the last review · 1
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
Every row write path returns the limit error when a value does not fit in its PostgreSQL B-tree index entry.
It gated on _APP_DB_ADAPTER, and no adapter capability describes the index entry size limit to gate on instead.
What changed
Row create, update and upsert endpoints (single and bulk:
Documents/Create.php,Update.php,Upsert.php,Bulk/Upsert.php,Bulk/Update.php) now catchUtopia\Database\Exception\Limitand return400with the database message, using the API's limit error (column_limit_exceededfor TablesDB,attribute_limit_exceededfor Collections). This matches what the transaction commit and increment/decrement already do.On Postgres, a value too large for a B-tree index (SQLSTATE
54000) is already mapped toLimitby utopia-php/database, but these endpoints did not catch it, so it returned500 general_unknown.Verification
On the local Postgres stack: a TablesDB table with a
varchar(700)column and akeyindex on it, then a row with 700 random 4-byte emoji (about 2,800 bytes).createRowgeneral_unknowncolumn_limit_exceededupdateRowupsertRowcreateRows(one of two rows too large)upsertRowsupdateRowsattribute_limit_exceededThe legacy Collections API
createDocumentreturns400 attribute_limit_exceeded. Pint and PHPStan pass on the changed files.Fixes #14335