From eb7f712379fec391d4b6d5287e0c3d6e16a5e8dc Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 14:52:07 +0900 Subject: [PATCH 1/6] Sync with 1.6.x changes - Added migration for `files` metadata size increase - Disabled `specification` migration until variable runtime specs are ready - Unset `key` for runtimes in response filters - Set the correct attribute `scopes` to be optional, reverting it for key and setting it for functions. --- app/config/collections.php | 8 ++++---- src/Appwrite/Migration/Version/V21.php | 13 ++++++++++++- src/Appwrite/Utopia/Response/Filters/V18.php | 7 +++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index e4dadcf0fc..e214f52bc6 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3061,8 +3061,8 @@ $projectCollections = array_merge([ 'format' => '', 'size' => Database::LENGTH_KEY, 'signed' => true, - 'required' => true, - 'default' => null, + 'required' => false, + 'default' => [], 'array' => true, 'filters' => [], ], @@ -4784,8 +4784,8 @@ $consoleCollections = array_merge([ 'format' => '', 'size' => Database::LENGTH_KEY, 'signed' => true, - 'required' => false, - 'default' => [], + 'required' => true, + 'default' => null, 'array' => true, 'filters' => [], ], diff --git a/src/Appwrite/Migration/Version/V21.php b/src/Appwrite/Migration/Version/V21.php index 1f540b3fda..7a4309cf93 100644 --- a/src/Appwrite/Migration/Version/V21.php +++ b/src/Appwrite/Migration/Version/V21.php @@ -148,6 +148,17 @@ class V21 extends Migration } catch (\Throwable $th) { Console::warning("'scheduleId' from {$id}: {$th->getMessage()}"); } + break; + case 'files': + try { + /** + * Increase metadata size to 7500 + */ + $this->projectDB->updateAttribute($id, 'metadata', size: 75000); + } catch (\Throwable $th) { + Console::warning("'metadata' from {$id}: {$th->getMessage()}"); + } + break; } usleep(50000); @@ -177,7 +188,7 @@ class V21 extends Migration $document->setAttribute('scopes', []); // Add size attribute - $document->setAttribute('specification', APP_FUNCTION_BASE_SPECIFICATION); + // $document->setAttribute('specification', APP_FUNCTION_BASE_SPECIFICATION); Uncomment after we merge variable runtimes specifications. } return $document; diff --git a/src/Appwrite/Utopia/Response/Filters/V18.php b/src/Appwrite/Utopia/Response/Filters/V18.php index 6485b6f0ba..d820b2509f 100644 --- a/src/Appwrite/Utopia/Response/Filters/V18.php +++ b/src/Appwrite/Utopia/Response/Filters/V18.php @@ -16,6 +16,7 @@ class V18 extends Filter Response::MODEL_FUNCTION => $this->parseFunction($content), Response::MODEL_EXECUTION => $this->parseExecution($content), Response::MODEL_PROJECT => $this->parseProject($content), + Response::MODEL_RUNTIME => $this->parseRuntime($content), default => $parsedResponse, }; @@ -46,4 +47,10 @@ class V18 extends Filter unset($content['authSessionAlerts']); return $content; } + + protected function parseRuntime(array $content) + { + unset($content['key']); + return $content; + } } From 0488a4582b4830876fb8fd675618bb68bfb87cd2 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 14:56:43 +0900 Subject: [PATCH 2/6] Add tests --- .../unit/Utopia/Response/Filters/V18Test.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/Utopia/Response/Filters/V18Test.php b/tests/unit/Utopia/Response/Filters/V18Test.php index 5396779b77..ec4ffb68fc 100644 --- a/tests/unit/Utopia/Response/Filters/V18Test.php +++ b/tests/unit/Utopia/Response/Filters/V18Test.php @@ -147,4 +147,29 @@ class V18Test extends TestCase $this->assertEquals($expected, $result); } + + public function runtimeProvider(): array + { + return [ + 'remove key' => [ + [ + 'key' => 'example_key', + ], + [ + ] + ] + ]; + } + + /** + * @dataProvider runtimeProvider + */ + public function testRuntime(array $content, array $expected): void + { + $model = Response::MODEL_RUNTIME; + + $result = $this->filter->parse($content, $model); + + $this->assertEquals($expected, $result); + } } From d52ab783d0a78894d4a67183abd9b2cad6002f27 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 17:51:16 +0900 Subject: [PATCH 3/6] Add specification to response filter --- src/Appwrite/Utopia/Response/Filters/V18.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Utopia/Response/Filters/V18.php b/src/Appwrite/Utopia/Response/Filters/V18.php index d820b2509f..0a74a2afed 100644 --- a/src/Appwrite/Utopia/Response/Filters/V18.php +++ b/src/Appwrite/Utopia/Response/Filters/V18.php @@ -38,6 +38,7 @@ class V18 extends Filter protected function parseFunction(array $content) { unset($content['scopes']); + unset($content['specification']); return $content; } From 04e7434932c57c62c4e51ad3d36f18a0a45643c0 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 18:07:10 +0900 Subject: [PATCH 4/6] Address Christy's Comments --- src/Appwrite/Migration/Version/V21.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/Appwrite/Migration/Version/V21.php b/src/Appwrite/Migration/Version/V21.php index 7a4309cf93..5dc8e159b4 100644 --- a/src/Appwrite/Migration/Version/V21.php +++ b/src/Appwrite/Migration/Version/V21.php @@ -149,16 +149,6 @@ class V21 extends Migration Console::warning("'scheduleId' from {$id}: {$th->getMessage()}"); } break; - case 'files': - try { - /** - * Increase metadata size to 7500 - */ - $this->projectDB->updateAttribute($id, 'metadata', size: 75000); - } catch (\Throwable $th) { - Console::warning("'metadata' from {$id}: {$th->getMessage()}"); - } - break; } usleep(50000); @@ -205,7 +195,7 @@ class V21 extends Migration $bucketId = 'bucket_' . $bucket['$internalId']; try { - $this->projectDB->updateAttribute($bucketId, 'metadata', size: 75000); + $this->projectDB->updateAttribute($bucketId, 'metadata', size: 65000); $this->projectDB->purgeCachedCollection($bucketId); } catch (\Throwable $th) { Console::warning("'bucketId' from {$bucketId}: {$th->getMessage()}"); From 4e5a2f71cc680f67892dbcb73adb437bc5c78c6e Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 18:34:52 +0900 Subject: [PATCH 5/6] Change self-hosted update to 75K --- src/Appwrite/Migration/Version/V21.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Migration/Version/V21.php b/src/Appwrite/Migration/Version/V21.php index 5dc8e159b4..835b24f201 100644 --- a/src/Appwrite/Migration/Version/V21.php +++ b/src/Appwrite/Migration/Version/V21.php @@ -195,7 +195,7 @@ class V21 extends Migration $bucketId = 'bucket_' . $bucket['$internalId']; try { - $this->projectDB->updateAttribute($bucketId, 'metadata', size: 65000); + $this->projectDB->updateAttribute($bucketId, 'metadata', size: 75000); $this->projectDB->purgeCachedCollection($bucketId); } catch (\Throwable $th) { Console::warning("'bucketId' from {$bucketId}: {$th->getMessage()}"); From e37c79cf3ceb17fc9310b97d50ea7e4dfb4d06de Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 19 Aug 2024 18:43:50 +0900 Subject: [PATCH 6/6] Update to 65534 --- src/Appwrite/Migration/Version/V21.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Migration/Version/V21.php b/src/Appwrite/Migration/Version/V21.php index 835b24f201..3a1959a70b 100644 --- a/src/Appwrite/Migration/Version/V21.php +++ b/src/Appwrite/Migration/Version/V21.php @@ -195,7 +195,7 @@ class V21 extends Migration $bucketId = 'bucket_' . $bucket['$internalId']; try { - $this->projectDB->updateAttribute($bucketId, 'metadata', size: 75000); + $this->projectDB->updateAttribute($bucketId, 'metadata', size: 65534); $this->projectDB->purgeCachedCollection($bucketId); } catch (\Throwable $th) { Console::warning("'bucketId' from {$bucketId}: {$th->getMessage()}");