Repository navigation
fix(databases): name the record, field and ID in increment and bulk write errors - #14582
Conversation
…rite errors
An increment or decrement that hit a missing row answered column_not_found,
and both a missing row and a missing column printed the raw "%s" because the
exception was thrown without params. The action now tells them apart by
reading the row back, and names the row ID or the column key.
The bound and not-a-number messages started with the SDK namespace
("tablesDB "n" ..."); they now name the field ("Column "n" ...").
A bulk create that repeated an ID, or reused a stored one, answered "Row with
the requested ID '' already exists", and a bulk upsert answered 'multiple'.
Both now name the repeated ID, or the first stored one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
The change reworks error reporting so duplicate-ID, missing-document, missing-attribute, and counter min/max failures carry the offending
Reviewed commit: ce34e5c |
Security rulesNo new WARNING or ERROR findings from security rules. 19 existing findings tracked in
|
There was a problem hiding this comment.
This PR improves user-facing error messages across the Databases Documents/Tables APIs by adding contextual params to duplicate, not-found, and limit exceptions, and introduces a new e2e ErrorMessages suite covering those contracts.
Key findings
- 🟡 Authorization-skip probe leaks document existence — Increment.php:187
🟢 Tier S · Ready to merge
This pull request corrects database error messages for increment/decrement operations, transaction commits, and duplicate IDs in bulk writes. It distinguishes missing rows from missing fields, names the affected fields and IDs, and adds E2E coverage across the database API variants, including permission-hidden rows. Latest changes: The newest commits handle authorization failures in increment/decrement requests and add E2E coverage verifying that rows the caller cannot read are reported like missing rows.
📂 Walkthrough · 8
Merged |
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…s a missing row Telling a missing row from a missing column read the row back without permissions, so a caller learned whether a row it could not read existed: row_not_found for an absent ID, column_not_found for a hidden row. A caller that could not update a hidden row got user_unauthorized for it, also unlike an absent ID. The row is now read back with the caller's permissions, and a row it cannot read answers row_not_found or document_not_found with the same message as an absent one, for a missing column and for a refused update alike. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The findings that requested changes are resolved. See the summary comment for what is still open.
What
Staging QA found several error messages that were wrong or garbled:
maincolumn_not_found: "Column with the requested key '%s' could not be found."%smax/ decrement pastmintablesDB "count" has reached the maximum value of 5tablesDB "label" is not a numberFix
Increment.php / Decrement.php. The library throws
NotFoundboth for a missing document and for a missing attribute. OnNotFound, the action now reads the row back with the caller's permissions:row_not_found/document_not_foundwith the row ID.column_not_found/attribute_not_foundwith the column key.The library's
Authorizationrefusal gets the same treatment: an unreadable row answers as missing, and a readable row the caller can't update answersuser_unauthorized. Either way, a caller learns nothing about rows it can't read.Bound and type messages name the field (
Column "count"orAttribute "count") instead ofgetSDKNamespace(). That covers Increment, Decrement and the transaction commit path inTransactions/Update.php.Bulk create and bulk upsert duplicates go through a new
getBatchDuplicateException()in the documentsAction. It names the ID the batch repeats, or else the first batch ID already stored (onefindOneon the error path). If neither lookup finds an ID, it uses a generic message instead of printing''.Out of scope:
"in the index-length message is in utopia-php/database (separate PR)....808is inpackages/validators(separate PR).Tests
The fixes are in the HTTP actions, so the E2E tests are the fixing-layer tests (
tests/e2e/Services/Databases/ErrorMessages.php, used byDatabasesBase):mainmaintestIncrementOfAMissingRecordNamesTheRecordcolumn_not_foundrow_not_found, "Row with the requested ID 'missing' …"attribute_not_foundtestIncrementOfARowTheCallerCannotReadLooksLikeAMissingRow(client user, no read/update on the row; absent ID vs hidden row, missing and existing column, increment and decrement)column_not_found '%s'/401for the hidden rowrow_not_foundtestIncrementOfAMissingFieldNamesTheField'%s''nope''%s'testIncrementPastItsBoundNamesTheFieldtablesDB "count"…Column "count" has reached the maximum value of 5/minimum value of 0databases "count"…testCommittedIncrementOfANonNumericFieldNamesTheFieldtablesDB "label" is not a numberColumn "label" is not a numberdatabases "label"…testBulkCreateOfAnExistingIdNamesTheIdID ''testBulkCreateOfARepeatedIdNamesTheIdID ''testBulkUpsertOfARepeatedIdNamesTheIdID 'multiple''multiple'Also passing locally: every increment, decrement, bulk and upsert test in the TablesDB, Legacy and DocumentsDB server suites, plus the full TablesDB and Legacy transaction suites. The one exception is
testCommitEventPayloadCarriesSurfaceIds, which fails the same way onmainin my local stack because of webhook delivery.🤖 Generated with Claude Code