From ea613301dc8a1ecd301fd41c34afbc8b69a3907e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 1 May 2026 15:32:03 +1200 Subject: [PATCH] fix(vectorsdb): expose collection logs endpoint and decouple from project DB - Add ListCollectionLogs route at /v1/vectorsdb/:databaseId/collections/:collectionId/logs via a thin subclass of the Databases collection logs handler. The endpoint was missing entirely, so VectorsDBConsoleClientTest::testGetCollectionLogs always 404'd. - In the parent Databases collection logs handler, drop the redundant getCollection() lookup. The schema fetch was only used for an emptiness guard, but vectorsdb collections live on a different DB connection (_APP_DB_ADAPTER_VECTORSDB), so the lookup returned empty and surfaced as COLLECTION_NOT_FOUND even when the metadata document existed. Checking $collectionDocument->isEmpty() covers both standard and vectorsdb cases and removes a wasted query on the hot path. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Http/Databases/Collections/Logs/XList.php | 3 +- .../Http/VectorsDB/Collections/Logs/XList.php | 58 +++++++++++++++++++ .../Databases/Services/Registry/VectorsDB.php | 2 + 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Logs/XList.php diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php index cc082532f9..06c8947563 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Logs/XList.php @@ -85,9 +85,8 @@ class XList extends Action } $collectionDocument = $dbForProject->getDocument('database_' . $database->getSequence(), $collectionId); - $collection = $dbForProject->getCollection('database_' . $database->getSequence() . '_collection_' . $collectionDocument->getSequence()); - if ($collection->isEmpty()) { + if ($collectionDocument->isEmpty()) { throw new Exception($this->getNotFoundException(), params: [$collectionId]); } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Logs/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Logs/XList.php new file mode 100644 index 0000000000..702f4c6794 --- /dev/null +++ b/src/Appwrite/Platform/Modules/Databases/Http/VectorsDB/Collections/Logs/XList.php @@ -0,0 +1,58 @@ +setHttpMethod(self::HTTP_REQUEST_METHOD_GET) + ->setHttpPath('/v1/vectorsdb/:databaseId/collections/:collectionId/logs') + ->desc('List collection logs') + ->groups(['api', 'database']) + ->label('scope', 'collections.read') + ->label('resourceType', RESOURCE_TYPE_DATABASES) + ->label('sdk', new Method( + namespace: 'vectorsDB', + group: null, + name: 'listCollectionLogs', + description: '/docs/references/vectorsdb/get-collection-logs.md', + auth: [AuthType::ADMIN], + responses: [ + new SDKResponse( + code: SwooleResponse::STATUS_CODE_OK, + model: UtopiaResponse::MODEL_LOG_LIST, + ), + ], + contentType: ContentType::JSON, + )) + ->param('databaseId', '', new UID(), 'Database ID.') + ->param('collectionId', '', new UID(), 'Collection ID.') + ->param('queries', [], new Queries([new Limit(), new Offset()]), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset', true) + ->inject('response') + ->inject('dbForProject') + ->inject('locale') + ->inject('geodb') + ->inject('authorization') + ->inject('audit') + ->callback($this->action(...)); + } +} diff --git a/src/Appwrite/Platform/Modules/Databases/Services/Registry/VectorsDB.php b/src/Appwrite/Platform/Modules/Databases/Services/Registry/VectorsDB.php index fe96d51d20..deba9388f0 100644 --- a/src/Appwrite/Platform/Modules/Databases/Services/Registry/VectorsDB.php +++ b/src/Appwrite/Platform/Modules/Databases/Services/Registry/VectorsDB.php @@ -18,6 +18,7 @@ use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Indexes\Creat use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Indexes\Delete as DeleteIndex; use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Indexes\Get as GetIndex; use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Indexes\XList as ListIndexes; +use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Logs\XList as ListCollectionLogs; use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Update as UpdateCollection; use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\Usage\Get as GetCollectionUsage; use Appwrite\Platform\Modules\Databases\Http\VectorsDB\Collections\XList as ListCollections; @@ -68,6 +69,7 @@ class VectorsDB extends Base $service->addAction(DeleteCollection::getName(), new DeleteCollection()); $service->addAction(ListCollections::getName(), new ListCollections()); $service->addAction(GetCollectionUsage::getName(), new GetCollectionUsage()); + $service->addAction(ListCollectionLogs::getName(), new ListCollectionLogs()); } private function registerIndexActions(Service $service): void