From 0b5e55fb4b22dc4a5931fe9290d1e2ff8db9e762 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Jul 2026 14:18:29 +0000 Subject: [PATCH 1/2] Fix usage attribution for database read endpoints Usage is attributed to a resource via the per-route `usage.resource` label, which is rendered into a resourcePath and parsed back into resourceType/resourceId by the stats worker. The parser only caps a database path to the table/collection level when the rendered path carries a `table`/`collection` segment; otherwise it falls back to the database. The TablesDB, DocumentsDB, VectorsDB and legacy Databases read endpoints (Get/List of tables, collections, rows, documents, columns, indexes, attributes) declared only `database/{databaseId}`, omitting the table or collection they operate on even though the id is present in the route. As a result these high-volume reads were bucketed under the parent database instead of the actual table/collection, while the write endpoints attributed correctly. Add the missing `/table/{tableId}` and `/collection/{collectionId}` segments to those reads, and fix two related label defects: - VectorsDB index create referenced `{request.tableId}` where the route param is `collectionId`. - Legacy collection update used the plural `collections` segment, which the parser does not recognise, so it fell back to the database. Container-level operations (get/delete a database, list its tables or collections) are left at database scope, which is correct. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01W2kBd7MvABcRZEA9uXhduY --- .../Databases/Http/Databases/Collections/Attributes/Get.php | 2 +- .../Databases/Http/Databases/Collections/Attributes/XList.php | 2 +- .../Modules/Databases/Http/Databases/Collections/Get.php | 2 +- .../Databases/Http/Databases/Collections/Indexes/Get.php | 2 +- .../Databases/Http/Databases/Collections/Indexes/XList.php | 2 +- .../Modules/Databases/Http/Databases/Collections/Update.php | 2 +- .../Databases/Http/DocumentsDB/Collections/Documents/Get.php | 2 +- .../Databases/Http/DocumentsDB/Collections/Documents/XList.php | 2 +- .../Modules/Databases/Http/DocumentsDB/Collections/Get.php | 2 +- .../Databases/Http/DocumentsDB/Collections/Indexes/Get.php | 2 +- .../Databases/Http/DocumentsDB/Collections/Indexes/XList.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Columns/Get.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Columns/XList.php | 2 +- .../Platform/Modules/Databases/Http/TablesDB/Tables/Get.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Rows/Get.php | 2 +- .../Modules/Databases/Http/TablesDB/Tables/Rows/XList.php | 2 +- .../Databases/Http/VectorsDB/Collections/Documents/Get.php | 2 +- .../Databases/Http/VectorsDB/Collections/Documents/XList.php | 2 +- .../Modules/Databases/Http/VectorsDB/Collections/Get.php | 2 +- .../Databases/Http/VectorsDB/Collections/Indexes/Create.php | 2 +- .../Databases/Http/VectorsDB/Collections/Indexes/Get.php | 2 +- .../Databases/Http/VectorsDB/Collections/Indexes/XList.php | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php index 61c7760eed..88152f3903 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php @@ -45,7 +45,7 @@ class Get extends Action ->desc('Get attribute') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php index 6390797407..84bf474dcd 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php @@ -40,7 +40,7 @@ class XList extends Action ->desc('List attributes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php index 64667f52c0..dc4974d9bf 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Get.php @@ -34,7 +34,7 @@ class Get extends Action ->desc('Get collection') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'databases', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php index 39e951e100..4082b7cd65 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Get.php @@ -35,7 +35,7 @@ class Get extends Action ->desc('Get index') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php index 506b45a890..bf926f158f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/XList.php @@ -41,7 +41,7 @@ class XList extends Action ->desc('List indexes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php index 5e4bcc1226..ff3810874e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php @@ -44,7 +44,7 @@ class Update extends Action ->label('event', 'databases.[databaseId].collections.[collectionId].update') ->label('audits.event', 'collection.update') ->label('audits.resource', 'database/{request.databaseId}/collections/{request.collectionId}') - ->label('usage.resource', 'database/{request.databaseId}/collections/{request.collectionId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk', new Method( namespace: 'databases', group: $this->getSDKGroup(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/Get.php index ec02abe2aa..bd51b51265 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/Get.php @@ -33,7 +33,7 @@ class Get extends DocumentGet ->desc('Get document') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'documentsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/XList.php index f2da8d262b..54bae436ba 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Documents/XList.php @@ -35,7 +35,7 @@ class XList extends DocumentXList ->desc('List documents') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'documentsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Get.php index d112f919e2..835c98567a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Get.php @@ -31,7 +31,7 @@ class Get extends CollectionGet ->desc('Get collection') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'documentsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Get.php index 567abaefed..3809233288 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/Get.php @@ -32,7 +32,7 @@ class Get extends IndexGet ->desc('Get index') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'documentsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/XList.php index 93ffb8fb55..493052f3df 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Indexes/XList.php @@ -33,7 +33,7 @@ class XList extends IndexXList ->desc('List indexes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'documentsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php index 9885f44ca4..b87b104374 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/Get.php @@ -43,7 +43,7 @@ class Get extends AttributesGet ->desc('Get column') ->groups(['api', 'database']) ->label('scope', ['tables.read', 'collections.read', 'columns.read', 'attributes.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php index 643ff94db4..9114138a34 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Columns/XList.php @@ -34,7 +34,7 @@ class XList extends AttributesXList ->desc('List columns') ->groups(['api', 'database']) ->label('scope', ['tables.read', 'collections.read', 'columns.read', 'attributes.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php index f7d61f0ebe..46ef13fdf5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Get.php @@ -32,7 +32,7 @@ class Get extends CollectionGet ->desc('Get table') ->groups(['api', 'database']) ->label('scope', ['tables.read', 'collections.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php index 96e185e01a..84f5a3f871 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/Get.php @@ -33,7 +33,7 @@ class Get extends IndexGet ->desc('Get index') ->groups(['api', 'database']) ->label('scope', ['tables.read', 'collections.read', 'indexes.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php index b67ea60f44..32ed2d8333 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Indexes/XList.php @@ -34,7 +34,7 @@ class XList extends IndexXList ->desc('List indexes') ->groups(['api', 'database']) ->label('scope', ['tables.read', 'collections.read', 'indexes.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php index 4b5b427f88..034216b51f 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/Get.php @@ -35,7 +35,7 @@ class Get extends DocumentGet ->desc('Get row') ->groups(['api', 'database']) ->label('scope', ['rows.read', 'documents.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php index b951fec8f8..f207781565 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Rows/XList.php @@ -37,7 +37,7 @@ class XList extends DocumentXList ->desc('List rows') ->groups(['api', 'database']) ->label('scope', ['rows.read', 'documents.read']) - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/table/{request.tableId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: $this->getSDKNamespace(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/Get.php index 35dc3f178a..10146b557e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/Get.php @@ -33,7 +33,7 @@ class Get extends DocumentGet ->desc('Get document') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'vectorsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/XList.php index 1b11b282fd..da45627fe3 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Documents/XList.php @@ -35,7 +35,7 @@ class XList extends DocumentXList ->desc('List documents') ->groups(['api', 'database']) ->label('scope', 'documents.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'vectorsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Get.php index 73c0a9d3dc..7a04bc9c6d 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Get.php @@ -31,7 +31,7 @@ class Get extends CollectionGet ->desc('Get collection') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'vectorsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php index f7b05690dd..441e1fe627 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php @@ -42,7 +42,7 @@ class Create extends IndexCreate ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'index.create') ->label('audits.resource', 'database/{request.databaseId}/collection/{request.tableId}') - ->label('usage.resource', 'database/{request.databaseId}/collection/{request.tableId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk', new Method( namespace: 'vectorsDB', group: $this->getSdkGroup(), diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Get.php index 3d1b492ff9..43d55db0ae 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Get.php @@ -32,7 +32,7 @@ class Get extends IndexGet ->desc('Get index') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'vectorsDB', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/XList.php index 8475349979..ccd0276a3b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/XList.php @@ -33,7 +33,7 @@ class XList extends IndexXList ->desc('List indexes') ->groups(['api', 'database']) ->label('scope', 'collections.read') - ->label('usage.resource', 'database/{request.databaseId}') + ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('sdk', new Method( namespace: 'vectorsDB', From 57cda9d88c9ecc77910195d72e2942ec85e70fbc Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Jul 2026 14:52:02 +0000 Subject: [PATCH 2/2] Fix audits.resource container id for VectorsDB index create and legacy collection update The audits.resource labels carried the same defects just fixed for usage.resource: VectorsDB index creation referenced {request.tableId} on a route that only declares :collectionId (writing an empty container id into every index-create audit record), and the legacy collection update used the plural `collections` segment, fragmenting its audit records from every other collection operation. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01W2kBd7MvABcRZEA9uXhduY --- .../Modules/Databases/Http/Databases/Collections/Update.php | 2 +- .../Databases/Http/VectorsDB/Collections/Indexes/Create.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php index ff3810874e..b82ea7ab71 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Update.php @@ -43,7 +43,7 @@ class Update extends Action ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('event', 'databases.[databaseId].collections.[collectionId].update') ->label('audits.event', 'collection.update') - ->label('audits.resource', 'database/{request.databaseId}/collections/{request.collectionId}') + ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk', new Method( namespace: 'databases', diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php index 441e1fe627..5912faf47b 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Indexes/Create.php @@ -41,7 +41,7 @@ class Create extends IndexCreate ->label('scope', 'collections.write') ->label('resourceType', RESOURCE_TYPE_DATABASES) ->label('audits.event', 'index.create') - ->label('audits.resource', 'database/{request.databaseId}/collection/{request.tableId}') + ->label('audits.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('usage.resource', 'database/{request.databaseId}/collection/{request.collectionId}') ->label('sdk', new Method( namespace: 'vectorsDB',