Skip to content

chore: bump utopia-php/audit to 4.0.0 and utopia-php/usage to 0.15.0 - #13361

Merged
lohanidamodar merged 1 commit into
mainfrom
chore/bump-audit-4-usage-0.15
Aug 26, 2026
Merged

lohanidamodar merged 1 commit into
mainfrom
chore/bump-audit-4-usage-0.15

Conversation

@lohanidamodar

Copy link
Copy Markdown
Member

What does this PR do?

Reapplies #13332, which was reverted in #13356. Same change, rebased onto current main — the lock needed no further resolution (composer update on the three packages reported "Nothing to modify in lock file").

Bumps utopia-php/audit to 4.0.0 and utopia-php/usage to 0.15.0.

They have to move together. Both moved to utopia-php/query 0.6; audit 4.0 and usage 0.15 each require utopia-php/query: 0.6.*, while the currently locked audit 3.0.2 and usage 0.14.0 both require 0.1.*. Bumping either alone leaves the tree unresolvable:

utopia-php/audit 4.0.0 requires utopia-php/query 0.6.*
  -> found utopia-php/query[0.6.0] but these were not loaded,
     likely because it conflicts with another require.

(Note "utopia-php/usage": "^0.14.0" excludes 0.15.0 on its own — Composer's caret on a 0.x version only allows the patch range.)

The lock diff is exactly three packages — audit 3.0.2 → 4.0.0, usage 0.14.0 → 0.15.0, query 0.1.1 → 0.6.0. Nothing else moves.

Code changes

The audit surface needed no changes — CE only calls new Audit(new AdapterDatabase($db)) and ->setup(), and both signatures are identical between 3.0.2 and 4.0.0.

The usage endpoints did need adapting, in src/Appwrite/Platform/Modules/Usage/Http/:

  • VALID_FILTER_METHODS in Events/XList.php and Gauges/XList.php referenced Query::TYPE_EQUAL and friends. Those constants no longer exist in query 0.6, so accessing them throws Error: Undefined constant. They now hold Method enum cases.
  • Action.php::parseFilterQueries() compared $query->getMethod() — now a Method enum — against that list of strings with in_array(..., true). That comparison is always false, so once the constants existed again every filter query on /usage/events and /usage/gauges would have been rejected with GENERAL_QUERY_INVALID. It now compares enum to enum, and the error messages render $method->value (interpolating the enum itself would have been a TypeError).

Test Plan

Run on this branch against current main, with vendor installed from the updated lock:

  • composer validate — passes; lock is in sync with composer.json.
  • composer check (phpstan, full config) — No errors. It reported 13 before the code changes, which is how both issues above were found.
  • composer lint (pint) on the three changed files — passes.
  • vendor/bin/phpunit tests/unit/Platform — 254 tests, 832 assertions, all pass.

Every CE call site into both libraries was checked against the released tags: Audit::__construct, Audit::setup, Adapter\Database::__construct, and UsageQuery::{parse,aggregate,groupBy,groupByInterval} are unchanged. UsageQuery::parse() is inherited from the base Query, and its new $allowRaw argument is defaulted, so the existing call still resolves. The nine UsageQuery statics removed in 0.15.0 (extractGroupBy, isAggregate, removeGroupBy, …) have no callers in CE.

Worth a reviewer's eye on the filter-method change specifically, since that path is only covered by e2e tests, which need a running stack.

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs? — no API metadata changed; the filter surface accepts the same set of methods as before.

Reapplies #13332, which was reverted in #13356. Same change, rebased onto
current main; the lock needed no further resolution.

Both libraries moved to utopia-php/query 0.6, which replaces the
`Query::TYPE_*` string constants with the `Utopia\Query\Method` enum. They
have to be bumped together: audit 4.0 and usage 0.15 both require
`utopia-php/query: 0.6.*`, while the locked audit 3.0.2 and usage 0.14.0
both require `0.1.*`, so pinning either alone leaves the tree unresolvable.
(`"utopia-php/usage": "^0.14.0"` also excludes 0.15.0 on its own — Composer's
caret on a 0.x version only allows the patch range.)

Lock diff is exactly three packages: audit 3.0.2 -> 4.0.0,
usage 0.14.0 -> 0.15.0, query 0.1.1 -> 0.6.0.

The usage endpoints follow the enum: `VALID_FILTER_METHODS` holds `Method`
cases, and `parseFilterQueries()` compares against them directly. The old
`in_array($query->getMethod(), $allowedMethods, true)` compared an enum to
strings, which is always false, so every filter query would have been
rejected.
@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR upgrades utopia-php/audit to 4.0.0 and utopia-php/usage to 0.15.0 together with their shared utopia-php/query 0.6 dependency.

  • Replaces removed query method constants with Method enum cases on usage event and gauge filters.
  • Updates filter validation and error formatting to compare and display enum values.
  • Keeps the Composer manifest and lock file synchronized across the three package upgrades.

Confidence Score: 5/5

The PR appears safe to merge because no concrete changed-code failure remains.

The dependency constraints move together as required, and the usage filter paths consistently compare Query 0.6 Method enum cases while rendering their backed string values in errors.

Important Files Changed

Filename Overview
composer.json Updates the coordinated Audit and Usage dependency constraints to versions compatible with Query 0.6.
composer.lock Locks Audit 4.0.0, Usage 0.15.0, and Query 0.6.0 with mutually compatible requirements.
src/Appwrite/Platform/Modules/Usage/Http/Action.php Updates filter-method validation and error rendering to operate on Query 0.6 Method enum cases.
src/Appwrite/Platform/Modules/Usage/Http/Events/XList.php Converts the event filter allowlist from removed string constants to equivalent Method enum cases.
src/Appwrite/Platform/Modules/Usage/Http/Gauges/XList.php Converts the gauge filter allowlist from removed string constants to equivalent Method enum cases.

Reviews (1): Last reviewed commit: "chore: bump utopia-php/audit to 4.0.0 an..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → chore/bump-audit-4-usage-0.15 (after).

Metric Before After Change
🚀 Requests/sec 231.02 226.62 ⚪ -1.9%
⏱️ Latency P50 77.87 ms 78.9 ms ⚪ +1.3%
⏱️ Latency P95 165.82 ms 170.22 ms ⚪ +2.7%
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.9 170.22 14,193 226.62 +4.4
Account 134.69 260.91 747 12.4 +0.66
TablesDB 81.21 146.5 7,719 125.14 +1.15
Storage 65.32 141.84 3,735 62.64 +12.65
Functions 96.12 198.68 1,992 34.18 +6.26

Top API waits (after)

API request Max wait (ms)
storage.buckets.delete 440.77
tablesdb.rows.delete 430.52
functions.variables.update 430.3
storage.files.delete 423.1
tablesdb.rows.decrement 406.81

@lohanidamodar
lohanidamodar merged commit 8745a8a into main Aug 26, 2026
45 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.

2 participants