diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 3e0e366b6b..1a117999f2 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -33,6 +33,7 @@ use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Duplicate; +use Utopia\Database\Exception\Order as OrderException; use Utopia\Database\Exception\Query as QueryException; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; @@ -204,8 +205,12 @@ App::get('/v1/teams') } $filterQueries = Query::groupByType($queries)['filters']; - - $results = $dbForProject->find('teams', $queries); + try { + $results = $dbForProject->find('teams', $queries); + } catch (OrderException $e) { + $message = "The order attribute '{$e->getAttribute()}' had a null value. Cursor pagination requires all documents order attribute values are non-null."; + throw new Exception(Exception::DATABASE_QUERY_ORDER_NULL,$message); + } $total = $dbForProject->count('teams', $filterQueries, APP_LIMIT_COUNT); $response->dynamic(new Document([ @@ -859,11 +864,15 @@ App::get('/v1/teams/:teamId/memberships') } $filterQueries = Query::groupByType($queries)['filters']; - - $memberships = $dbForProject->find( - collection: 'memberships', - queries: $queries, - ); + try { + $memberships = $dbForProject->find( + collection: 'memberships', + queries: $queries, + ); + } catch (OrderException $e) { + $message = "The order attribute '{$e->getAttribute()}' had a null value. Cursor pagination requires all documents order attribute values are non-null."; + throw new Exception(Exception::DATABASE_QUERY_ORDER_NULL,$message); + } $total = $dbForProject->count( collection: 'memberships',