mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge pull request #10318 from appwrite/fix-catches
Fix uncaught invalid arg
This commit is contained in:
commit
405aa7f4ba
3 changed files with 44 additions and 20 deletions
|
|
@ -4493,7 +4493,7 @@ App::put('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
|
||||||
App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/:attribute/increment')
|
App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/:attribute/increment')
|
||||||
->desc('Increment document attribute')
|
->desc('Increment document attribute')
|
||||||
->groups(['api', 'database'])
|
->groups(['api', 'database'])
|
||||||
->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].increment')
|
->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].update')
|
||||||
->label('scope', 'documents.write')
|
->label('scope', 'documents.write')
|
||||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||||
->label('audits.event', 'documents.increment')
|
->label('audits.event', 'documents.increment')
|
||||||
|
|
@ -4552,6 +4552,8 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute "' . $attribute . '" has reached the maximum value of ' . $max);
|
throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute "' . $attribute . '" has reached the maximum value of ' . $max);
|
||||||
} catch (TypeException) {
|
} catch (TypeException) {
|
||||||
throw new Exception(Exception::ATTRIBUTE_TYPE_INVALID, 'Attribute "' . $attribute . '" is not a number');
|
throw new Exception(Exception::ATTRIBUTE_TYPE_INVALID, 'Attribute "' . $attribute . '" is not a number');
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$queueForStatsUsage
|
$queueForStatsUsage
|
||||||
|
|
@ -4561,6 +4563,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
$queueForEvents
|
$queueForEvents
|
||||||
->setParam('databaseId', $databaseId)
|
->setParam('databaseId', $databaseId)
|
||||||
->setParam('collectionId', $collectionId)
|
->setParam('collectionId', $collectionId)
|
||||||
|
->setParam('documentId', $document->getId())
|
||||||
->setContext('collection', $collection)
|
->setContext('collection', $collection)
|
||||||
->setContext('database', $database);
|
->setContext('database', $database);
|
||||||
|
|
||||||
|
|
@ -4570,7 +4573,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/:attribute/decrement')
|
App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:documentId/:attribute/decrement')
|
||||||
->desc('Decrement document attribute')
|
->desc('Decrement document attribute')
|
||||||
->groups(['api', 'database'])
|
->groups(['api', 'database'])
|
||||||
->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].decrement')
|
->label('event', 'databases.[databaseId].collections.[collectionId].documents.[documentId].update')
|
||||||
->label('scope', 'documents.write')
|
->label('scope', 'documents.write')
|
||||||
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
->label('resourceType', RESOURCE_TYPE_DATABASES)
|
||||||
->label('audits.event', 'documents.decrement')
|
->label('audits.event', 'documents.decrement')
|
||||||
|
|
@ -4629,6 +4632,8 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute "' . $attribute . '" has reached the minimum value of ' . $min);
|
throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute "' . $attribute . '" has reached the minimum value of ' . $min);
|
||||||
} catch (TypeException) {
|
} catch (TypeException) {
|
||||||
throw new Exception(Exception::ATTRIBUTE_TYPE_INVALID, 'Attribute "' . $attribute . '" is not a number');
|
throw new Exception(Exception::ATTRIBUTE_TYPE_INVALID, 'Attribute "' . $attribute . '" is not a number');
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$queueForStatsUsage
|
$queueForStatsUsage
|
||||||
|
|
@ -4638,6 +4643,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||||
$queueForEvents
|
$queueForEvents
|
||||||
->setParam('databaseId', $databaseId)
|
->setParam('databaseId', $databaseId)
|
||||||
->setParam('collectionId', $collectionId)
|
->setParam('collectionId', $collectionId)
|
||||||
|
->setParam('documentId', $document->getId())
|
||||||
->setContext('collection', $collection)
|
->setContext('collection', $collection)
|
||||||
->setContext('database', $database);
|
->setContext('database', $database);
|
||||||
|
|
||||||
|
|
|
||||||
36
composer.lock
generated
36
composer.lock
generated
|
|
@ -1228,16 +1228,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "open-telemetry/context",
|
"name": "open-telemetry/context",
|
||||||
"version": "1.3.0",
|
"version": "1.3.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/opentelemetry-php/context.git",
|
"url": "https://github.com/opentelemetry-php/context.git",
|
||||||
"reference": "4d5d98f1d4311a55b8d07e3d4c06d2430b4e6efc"
|
"reference": "438f71812242db3f196fb4c717c6f92cbc819be6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/opentelemetry-php/context/zipball/4d5d98f1d4311a55b8d07e3d4c06d2430b4e6efc",
|
"url": "https://api.github.com/repos/opentelemetry-php/context/zipball/438f71812242db3f196fb4c717c6f92cbc819be6",
|
||||||
"reference": "4d5d98f1d4311a55b8d07e3d4c06d2430b4e6efc",
|
"reference": "438f71812242db3f196fb4c717c6f92cbc819be6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -1283,7 +1283,7 @@
|
||||||
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
|
"issues": "https://github.com/open-telemetry/opentelemetry-php/issues",
|
||||||
"source": "https://github.com/open-telemetry/opentelemetry-php"
|
"source": "https://github.com/open-telemetry/opentelemetry-php"
|
||||||
},
|
},
|
||||||
"time": "2025-08-04T03:25:06+00:00"
|
"time": "2025-08-13T01:12:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "open-telemetry/exporter-otlp",
|
"name": "open-telemetry/exporter-otlp",
|
||||||
|
|
@ -3545,16 +3545,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/database",
|
"name": "utopia-php/database",
|
||||||
"version": "0.71.13",
|
"version": "0.71.14",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/utopia-php/database.git",
|
"url": "https://github.com/utopia-php/database.git",
|
||||||
"reference": "43aaba72b5699a06351b25924c3417ff83e6bb4b"
|
"reference": "20998e268ec528ebbf06adb77ec4230f70469fa7"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/43aaba72b5699a06351b25924c3417ff83e6bb4b",
|
"url": "https://api.github.com/repos/utopia-php/database/zipball/20998e268ec528ebbf06adb77ec4230f70469fa7",
|
||||||
"reference": "43aaba72b5699a06351b25924c3417ff83e6bb4b",
|
"reference": "20998e268ec528ebbf06adb77ec4230f70469fa7",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -3595,9 +3595,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/utopia-php/database/issues",
|
"issues": "https://github.com/utopia-php/database/issues",
|
||||||
"source": "https://github.com/utopia-php/database/tree/0.71.13"
|
"source": "https://github.com/utopia-php/database/tree/0.71.14"
|
||||||
},
|
},
|
||||||
"time": "2025-08-11T10:47:16+00:00"
|
"time": "2025-08-14T07:15:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "utopia-php/detector",
|
"name": "utopia-php/detector",
|
||||||
|
|
@ -5440,16 +5440,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "nikic/php-parser",
|
"name": "nikic/php-parser",
|
||||||
"version": "v5.6.0",
|
"version": "v5.6.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nikic/PHP-Parser.git",
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
"reference": "221b0d0fdf1369c71047ad1d18bb5880017bbc56"
|
"reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/221b0d0fdf1369c71047ad1d18bb5880017bbc56",
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2",
|
||||||
"reference": "221b0d0fdf1369c71047ad1d18bb5880017bbc56",
|
"reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
|
@ -5468,7 +5468,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "5.0-dev"
|
"dev-master": "5.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|
@ -5492,9 +5492,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
"source": "https://github.com/nikic/PHP-Parser/tree/v5.6.0"
|
"source": "https://github.com/nikic/PHP-Parser/tree/v5.6.1"
|
||||||
},
|
},
|
||||||
"time": "2025-07-27T20:03:57+00:00"
|
"time": "2025-08-13T20:13:15+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phar-io/manifest",
|
"name": "phar-io/manifest",
|
||||||
|
|
|
||||||
|
|
@ -5569,6 +5569,15 @@ trait DatabasesBase
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
]));
|
]));
|
||||||
$this->assertEquals(404, $notFound['headers']['status-code']);
|
$this->assertEquals(404, $notFound['headers']['status-code']);
|
||||||
|
|
||||||
|
// Test increment with value 0
|
||||||
|
$inc3 = $this->client->call(Client::METHOD_PATCH, "/databases/$databaseId/collections/$collectionId/documents/$docId/count/increment", array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
]), [
|
||||||
|
'value' => 0
|
||||||
|
]);
|
||||||
|
$this->assertEquals(400, $inc3['headers']['status-code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDecrementAttribute(): void
|
public function testDecrementAttribute(): void
|
||||||
|
|
@ -5690,6 +5699,15 @@ trait DatabasesBase
|
||||||
'x-appwrite-project' => $this->getProject()['$id'],
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
]), ['value' => 'not-a-number']);
|
]), ['value' => 'not-a-number']);
|
||||||
$this->assertEquals(400, $typeErr['headers']['status-code']);
|
$this->assertEquals(400, $typeErr['headers']['status-code']);
|
||||||
|
|
||||||
|
// Test decrement with value 0
|
||||||
|
$inc3 = $this->client->call(Client::METHOD_PATCH, "/databases/$databaseId/collections/$collectionId/documents/$documentId/count/increment", array_merge([
|
||||||
|
'content-type' => 'application/json',
|
||||||
|
'x-appwrite-project' => $this->getProject()['$id'],
|
||||||
|
]), [
|
||||||
|
'value' => 0
|
||||||
|
]);
|
||||||
|
$this->assertEquals(400, $inc3['headers']['status-code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue