diff --git a/app/config/errors.php b/app/config/errors.php index 9fadde6e93..2983d22cd8 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -403,9 +403,14 @@ return [ 'description' => 'The document structure is invalid. Please ensure the attributes match the collection definition.', 'code' => 400, ], + Exception::DOCUMENT_MISSING_DATA => [ + 'name' => Exception::DOCUMENT_MISSING_DATA, + 'description' => 'The document data is missing. You must provide the document data.', + 'code' => 400, + ], Exception::DOCUMENT_MISSING_PAYLOAD => [ 'name' => Exception::DOCUMENT_MISSING_PAYLOAD, - 'description' => 'The document payload is missing.', + 'description' => 'The document data and permissions are missing. You must provide either the document data or permissions to be updated.', 'code' => 400, ], Exception::DOCUMENT_ALREADY_EXISTS => [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index c4ff448ce4..a4de380561 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2653,7 +2653,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') $data = (\is_string($data)) ? \json_decode($data, true) : $data; // Cast to JSON array if (empty($data)) { - throw new Exception(Exception::DOCUMENT_MISSING_PAYLOAD); + throw new Exception(Exception::DOCUMENT_MISSING_DATA); } if (isset($data['$id'])) { diff --git a/src/Appwrite/Extend/Exception.php b/src/Appwrite/Extend/Exception.php index ebd12851e2..7ed022b452 100644 --- a/src/Appwrite/Extend/Exception.php +++ b/src/Appwrite/Extend/Exception.php @@ -134,6 +134,7 @@ class Exception extends \Exception /** Documents */ public const DOCUMENT_NOT_FOUND = 'document_not_found'; public const DOCUMENT_INVALID_STRUCTURE = 'document_invalid_structure'; + public const DOCUMENT_MISSING_DATA = 'document_missing_data'; public const DOCUMENT_MISSING_PAYLOAD = 'document_missing_payload'; public const DOCUMENT_ALREADY_EXISTS = 'document_already_exists'; public const DOCUMENT_UPDATE_CONFLICT = 'document_update_conflict';