Skip to content

chore(deps): bump utopia-php/database to ^8.3 and delete the stopgaps it replaces - #14560

Merged
abnegate merged 10 commits into
mainfrom
qfix-bump-database
Oct 15, 2026
Merged

abnegate merged 10 commits into
mainfrom
qfix-bump-database

Conversation

@abnegate

@abnegate abnegate commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

What

Bumps utopia-php/database to ^8.3 (8.3.0) in composer.json and in the monorepo packages that require it (abuse, audit, migration, usage), and deletes the server-side stopgaps that 8.3.0 now fixes at the source.

Stopgaps deleted

Deleted Came from Replaced by
XList::countRows() and PAGING_METHODS, which re-ran a grouped, distinct or aggregate read for up to APP_LIMIT_COUNT rows to get total. total goes back to count($queries, APP_LIMIT_COUNT) #14536 utopia-php/database#1020: count() counts grouped, distinct and aggregate reads by their rows
XList::$paged, which appended limit(APP_LIMIT_LIST_DEFAULT) only so countRows() could tell a short page from a full one. Queries go to the library as they did before #14536; its read defaults to a page of 25, the same as APP_LIMIT_LIST_DEFAULT #14536 utopia-php/database#1020
Appwrite\Utopia\Database\Validator\Query\Order, its wiring in XList and OrderTest #14543 utopia-php/database#1023: the library refuses ordering by a relationship that holds no column, with the same message (Invalid query: Cannot order by relationship attribute: <key>), as a QueryException. The list already maps that to 400 general_query_invalid
XList::assertRepresentable(), the is_float && !is_finite check on aggregate rows #14538 utopia-php/database#1018 and #1019: aggregate() refuses a non-finite sum, average, deviation or variance with Exception\Limit on every adapter. The existing catch (LimitException) still maps it to 400 database_query_out_of_range

Nothing on main reads the raw aggregate() row shape that #1024 changes: XList wraps each row in a Document. The response-shape work stays in #14537, which will be reworked onto 8.3.0 after this merges.

Tests that tolerated the old library are now strict

These now fail against the library behaviour they used to accept.

  • Typed aggregate rows (bump utopia/analytics to 0.2.0 #1024).
    • Oracle\Assertions::aggregateInteger() / aggregateFloat() require a real int / float. They no longer cast numeric strings.
    • groupedValue() requires the alias-qualified name (ord.label) and has no fallback to the bare column.
    • StatisticalAggregates and the aggregate tests in DatabasesBase (count, sum, avg, min/max, groupBy, countDistinct, join sum) assert the typed values with assertSame, assertIsInt and assertIsFloat, with no casts.
  • Overflow (Cannot install without access to Google Analytics #1018/Doc fixing broken environment variables link #1019). RejectedValues::testAggregateOverflowIsRejected expects 400 database_query_out_of_range for an overflowed sum on every adapter, not only PostgreSQL. A stddev of two equal values must be either 400 or 0.
  • Dotted paths (Admin Panel/Dashboard on different domain/route #1022).
    • New Queries/DottedPaths::testListRejectsADottedPathOnAPlainAttribute, for Databases and TablesDB. A filter and a select on title.x must answer 400 general_query_invalid on every adapter, MongoDB included, with no special case. Before 8.3.0, SQL answered 404 or 500 and MongoDB an empty 200.
    • New UsersBase::testListUsersRejectsADottedPathOnAPlainAttribute. /users validates queries as a param, so a filter on name.x answers 400 general_argument_invalid, like its other invalid-query cases. /users refuses select as a method of its own.
  • Unchanged. The e2e tests the stopgaps added stay, and now pass through the library:

Checks

Pint, PHPStan and Rector are clean locally. The unit suite passes, apart from local missing extensions (yaml, maxminddb, imagick).

🤖 Generated with Claude Code

abnegate and others added 6 commits October 16, 2026 01:03
8.3.0 counts grouped, distinct and aggregate reads by their rows (#1020),
refuses ordering by a relationship that holds no column (#1023), refuses a
dotted path on a plain attribute (#1022), types and names aggregate rows as
find() does (#1024) and refuses a floating aggregate that overflows
(#1018, #1019). The monorepo packages that require the library move to the
same floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he library

countRows() re-ran a grouped, distinct or aggregate read for up to
APP_LIMIT_COUNT rows because count() ignored groupBy, distinct and
aggregates. utopia-php/database#1020 counts them by their rows, so the
total goes back to count() with APP_LIMIT_COUNT.

The relationship order validator and its unit tests go too:
utopia-php/database#1023 refuses ordering by a relationship that holds no
column with the same message, as a QueryException the list already
answers with 400 general_query_invalid.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Staged changes overlay rows by document ID. A distinct row that leaves out
$id has none, so inside a transaction a staged delete or update never
reached it, a staged create was appended even when it duplicated a
distinct row, and the total counted those rows too. Such a read is refused
like an aggregate; a distinct read that selects $id still overlays.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
utopia-php/database#1022 refuses a filter or select on a dotted path under
a plain attribute before the adapter runs, on every adapter. Before it the
SQL engines answered 404 or 500 and MongoDB an empty 200.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php
assertRepresentable() turned a non-finite aggregate value into
database_query_out_of_range because the engines answered an overflowed
floating aggregate with 0, INF or DBL_MAX. utopia-php/database#1018 and
#1019 refuse it in aggregate() with Exception\Limit on every adapter,
which the list already maps to the same 400.

The overflow test now expects the 400 for the sum on every adapter, not
only PostgreSQL, and a 0 when an engine answers the deviation of two equal
values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

luxor-code-review Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review complete. No issues found.


The change moves query-validation responsibility for ordering and aggregate overflow from Appwrite-side code into the upgraded utopia-php/database 8.3 library, and extends TransactionState so distinct queries behave correctly inside transactions with staged writes.

Files Change
composer.json, packages/{abuse,audit,migration,usage}/composer.json Bump utopia-php/database constraints to ^8.3 across the monorepo
src/Appwrite/Utopia/Database/Validator/Query/Order.php Delete the app-side Order validator, now covered by the upstream library
src/Appwrite/Databases/TransactionState.php Add distinct-query overlay handling (assertOverlayable, select-$id staging) and drop local aggregate/countRows paths
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php Align dotted-path rejection with the new library error contract (general_query_invalid)
tests/unit/.../OrderTest.php, tests/e2e/Services/Databases/Queries/*, tests/e2e/Services/Users/UsersBase.php, tests/unit/Databases/TransactionStateTest.php Remove the obsolete validator test, tighten aggregate-overflow assertions, and add dotted-path plus distinct-in-transaction coverage

All parallel review passes and source-level verification found no confirmable defects at or above the reporting threshold; the main residual risk rests on unverifiable utopia-php/database 8.3 upstream behavior.

Reviewed commit: ec8f3b0

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ghost

ghost commented Oct 15, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Moves Appwrite and its database-dependent packages to utopia-php/database 8.3, removing local workarounds for query totals, aggregate overflow, and relationship ordering. It also rejects transactional distinct reads without $id and adds regression and API coverage for transactions, totals, aggregate result types, and dotted-path validation. The latest changes delegate default paging to the database library and tighten assertions for aggregate result types and joined group keys.

Latest changes: The latest commits remove the explicit default-limit query injection, strengthen aggregate type and joined-key assertions, and keep the users dotted-path test focused on filters because user selects are disallowed.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 13
File Change
composer.json, composer.lock, packages/abuse/composer.json, packages/audit/composer.json, packages/migration/composer.json, packages/usage/composer.json Bump the root and dependent monorepo packages to utopia-php/database ^8.3 and lock version 8.3.0.
src/Appwrite/Databases/TransactionState.php Reject transactional distinct reads that omit $id, which cannot correctly overlay staged rows.
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php Rely on library behavior for totals, aggregate overflow, relationship ordering, and default page sizing.
src/Appwrite/Utopia/Database/Validator/Query/Order.php, tests/unit/Utopia/Database/Validator/Query/OrderTest.php Remove the superseded relationship-order validator and its unit test.
tests/unit/Databases/TransactionStateTest.php Add regression coverage for distinct transaction reads without IDs and valid ID-backed overlays.
tests/e2e/Services/Databases/DatabasesBase.php Assert aggregate response types and retain coverage for grouped, distinct, and standard aggregate queries.
tests/e2e/Services/Databases/Queries/DottedPaths.php Cover invalid dotted paths on plain attributes through Databases and TablesDB.
tests/e2e/Services/Databases/Queries/Oracle/Assertions.php Assert native aggregate scalar types and qualified joined-group keys in oracle comparisons.
tests/e2e/Services/Databases/Queries/RejectedValues.php Exercise aggregate overflow rejection across adapters.
tests/e2e/Services/Databases/Queries/StatisticalAggregates.php Check statistical and bitwise aggregate values without coercing response types.
tests/e2e/Services/Users/UsersBase.php Cover invalid dotted-path filters for user listing.
composer.json Raises the root database dependency constraint to ^8.3.
composer.lock Locks utopia-php/database 8.3.0 and its updated query dependency.

Reviewed the commits since ec8f3b0 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → qfix-bump-database (after).

Metric Before After Change
🚀 Requests/sec 210.34 216.7 ⚪ +3%
⏱️ Latency P50 81.96 ms 78.92 ms ⚪ -3.7%
⏱️ Latency P95 195.59 ms 190.9 ms ⚪ -2.4%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 78.92 190.9 13,680 216.7 -4.69
Account 166.07 307.83 720 12.25 +36.22
TablesDB 75.92 142.46 7,440 121.24 -12.83
Storage 72.95 162.24 3,600 60.12 -16.62
Functions 119.39 231.96 1,920 32.69 +4.82

Top API waits (after)

API request Max wait (ms)
functions.create 493.94
account.name.update 490.33
functions.variables.update 412.84
functions.variables.create 412.45
account.prefs.update 395.42

abnegate and others added 4 commits October 16, 2026 01:21
This reverts eb129ad. Refusing a distinct read without $id inside a
transaction restricts reads that work today; the wrong total belongs to
TransactionState's overlay and gets its own fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
$paged appended limit(APP_LIMIT_LIST_DEFAULT) only so countRows() could
tell a short last page from a full one. countRows() is gone, and the
library's read already defaults to a page of 25, the same as
APP_LIMIT_LIST_DEFAULT.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
/users refuses select queries as a method of their own, so only the filter
reaches the attribute check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rns them

utopia-php/database#1024 types counts and bitwise aggregates as int,
statistics as float, an integer sum as int and min/max as the attribute,
and names a joined group by its alias. The assertions that cast numeric
strings or fell back to the bare joined column now require the typed value
and the qualified name, so they fail on a library that returns the raw row.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abnegate

Copy link
Copy Markdown
Member Author

Benchmark check: no regression from the database 8.3.0 bump.

At c652a6d946 the run reads +3.0% RPS (210.34 → 216.70), P50 −3.7% and P95 −2.4%. TablesDB P95 is −12.8 ms and Storage −16.6 ms.

The first run at 8487fc0879 read −7.2% RPS, but its main "before" was 174.39, the lowest of the day. Other runs today show how much main moves between runs on its own:

PR RPS before → after Account Δ P95
#14538 199.26 → 193.63 (−2.8%) +30.05
#14543 200.86 → 205.50 (+2.3%) −37.02
#14551 201.41 → 205.97 (+2.3%) −5.46
#14553 182.98 → 182.58 (−0.2%) −9.02
#14561 (usage only, no database change) 203.22 → 214.58 (+5.6%) +34.6

Main's "before" alone ranged from 174 to 216 RPS, and Account P95 moves ±30–37 ms on PRs that don't touch it, so the Account +36 ms here is within that noise.

I also ran a local library microbenchmark of 8.1.4 against 8.3.0 on MySQL 8.0. The two versions alternated, and each figure is the median per-operation time over 2 rounds:

Operation 8.1.4 8.3.0
createDocument 2060 / 2143 µs 2039 / 2016 µs
getDocument 894 / 870 µs 863 / 881 µs
find equal, limit 25 2847 / 2625 µs 2649 / 2657 µs
find order + offset 3304 / 3315 µs 3348 / 3280 µs
find select 3290 / 3410 µs 3132 / 2866 µs
count equal 1312 / 1376 µs 1247 / 1285 µs
updateDocument 2516 / 2664 µs 2585 / 2588 µs

8.3.0 is level with 8.1.4 or slightly faster on every hot path, including the new filter, select and order validation (#1022, #1023) and count() through plan() (#1020).

@abnegate
abnegate merged commit fd3e22d into main Oct 15, 2026
226 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant