Merge pull request #9841 from ArnabChatterjee20k/dat-532

added checking for encrypt and plan allowing encryption of string att…
This commit is contained in:
Jake Barnby 2025-05-21 08:51:31 +00:00 committed by GitHub
commit eab446a828
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -1347,7 +1347,11 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/attributes/string
->inject('dbForProject')
->inject('queueForDatabase')
->inject('queueForEvents')
->action(function (string $databaseId, string $collectionId, string $key, ?int $size, ?bool $required, ?string $default, bool $array, bool $encrypt, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents) {
->inject('plan')
->action(function (string $databaseId, string $collectionId, string $key, ?int $size, ?bool $required, ?string $default, bool $array, bool $encrypt, Response $response, Database $dbForProject, EventDatabase $queueForDatabase, Event $queueForEvents, array $plan) {
if ($encrypt && !empty($plan) && !($plan['databasesAllowEncrypt'] ?? false)) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Encrypted string attributes are not available on your plan. Please upgrade to create encrypted string attributes.');
}
// Ensure attribute default is within required size
$validator = new Text($size, 0);
if (!is_null($default) && !$validator->isValid($default)) {

View file

@ -695,7 +695,7 @@ class DatabasesCustomServerTest extends Scope
'key' => 'lastName',
'size' => 256,
'required' => true,
'encrypt' => true,
'encrypt' => true
]);