Repository navigation
fix(storage): add missing encryption/compression properties to File model with validated defaults - #12405
Conversation
|
|
|
||
| use Appwrite\Utopia\Response; | ||
| use Appwrite\Utopia\Response\Model; | ||
| use Utopia\Compression\Compression; |
There was a problem hiding this comment.
The
filter() method (and the rule descriptions/defaults) references Utopia\Compression\Compression from the transitive dependency utopia-php/compression, while every other file that works with the same algorithm database value — Bucket.php, Builds.php, Migrations.php, and storage.php — all import Utopia\Storage\Compression\Compression from the direct utopia-php/storage dependency. If the two classes ever diverge in their constant string values, the in_array validation in filter() would silently fall back to Compression::NONE for compressed files, causing them to be misreported as uncompressed in API responses. Using the same class as the rest of the codebase removes this risk and keeps the import consistent.
| use Utopia\Compression\Compression; | |
| use Utopia\Storage\Compression\Compression; |
…alidated defaults - Add encryption (bool) and compression (string) schema fields - Fix compression default from empty string to Compression::NONE - Add filter() to derive compression/encryption from document attributes - Validate compression against allowed values (none/gzip/zstd) - Fixes Flutter SDK crash when accessing file.encryption (issue appwrite#11647)
12d2e05 to
cf9a0a1
Compare
|
Rebased onto This PR targeted Closed #12524, which was the |
The first chunk of a chunked upload created the file document with 'algorithm' => '', and Document::getAttribute() only falls back to its default when the key is unset, so that empty string was returned as-is in the compression property. Write Compression::NONE instead, and fall back with ?: in the model so existing documents are covered too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Simplified the filter and added E2E coverage. Dropped the whitelist check — but it was load-bearing, so the underlying cause is fixed instead. public function getAttribute(string $name, mixed $default = null): mixed
{
if (isset($this[$name])) {
return $this[$name];
}
return $default;
}
So:
$document->setAttribute('compression', $document->getAttribute('algorithm') ?: Compression::NONE);E2E test in
|
The File model on main was missing the \encryption\ and \compression\ properties that exist in the 1.9.x branch. When the Flutter SDK (>= 20.3.3) tries to access \ile.encryption, it returns null instead of a boolean, causing a crash.
Changes
one/\gzip/\zstd)
Fixes
Closes #11647
This also addresses the code review feedback from #11652 where compression default was flagged as ''\ contradicting the documented closed set.