Skip to content

fix: add file encryption property - #12524

Closed
deepshekhardas wants to merge 3457 commits into
appwrite:1.9.xfrom
deepshekhardas:fix/11647-file-encryption-property
Closed

deepshekhardas wants to merge 3457 commits into
appwrite:1.9.xfrom
deepshekhardas:fix/11647-file-encryption-property

Conversation

@deepshekhardas

Copy link
Copy Markdown
Contributor

Fixes #11647

Adds missing file encryption property to storage file metadata.

@greptile-apps

greptile-apps Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule violations remain.

Fix All in Claude CodeFindings

  1. P1 The PR imports Utopia\Compression\Compression from utopia-php/compression , but every other file in the codebase that references compression constants - storage.php , Bucket.php , Migrations.php , Builds.php - uses Utopia\Storage\Compression\Compression from utopia-php/storage . The algorithm attribute stored on a file document is written using the storage package's constants. If the two classes define NONE , GZIP , or ZSTD with different string values, the \in array guard in filter will silently fall back to Compression NONE for legitimately compressed files, and the API will always report compression "none" for those files. ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Utopia/Response/Model/File.php:7-8
The PR imports `Utopia\Compression\Compression` (from `utopia-php/compression`), but every other file in the codebase that references compression constants - `storage.php`, `Bucket.php`, `Migrations.php`, `Builds.php` - uses `Utopia\Storage\Compression\Compression` (from `utopia-php/storage`). The `algorithm` attribute stored on a file document is written using the storage package's constants. If the two classes define `NONE`, `GZIP`, or `ZSTD` with different string values, the `\in_array` guard in `filter()` will silently fall back to `Compression::NONE` for legitimately compressed files, and the API will always report `compression: "none"` for those files.

```suggestion
use Utopia\Storage\Compression\Compression;
use Utopia\Database\Document;
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The latest change completes Storage file metadata serialization by giving compression a valid default and normalizing persisted compression values before exposing them.

  • Reports none when compression metadata is absent or invalid.
  • Preserves supported none, gzip, and zstd values.
  • Continues deriving encryption state from the persisted OpenSSL cipher metadata.
  • The previous compression-package mismatch finding is fully fixed because serialization and file creation now use the same constants.

Reviews (3) · Last reviewed commit: "fix(storage): add missing encryption/com..."

Comment on lines +7 to +8
use Utopia\Compression\Compression;
use Utopia\Database\Document;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 The PR imports Utopia\Compression\Compression (from utopia-php/compression), but every other file in the codebase that references compression constants — storage.php, Bucket.php, Migrations.php, Builds.php — uses Utopia\Storage\Compression\Compression (from utopia-php/storage). The algorithm attribute stored on a file document is written using the storage package's constants. If the two classes define NONE, GZIP, or ZSTD with different string values, the \in_array guard in filter() will silently fall back to Compression::NONE for legitimately compressed files, and the API will always report compression: "none" for those files.

Suggested change
use Utopia\Compression\Compression;
use Utopia\Database\Document;
use Utopia\Storage\Compression\Compression;
use Utopia\Database\Document;

loks0n and others added 28 commits September 15, 2026 10:24
…ouble

The double now answers region, accessedAt, order, limit and cursor queries,
so the tests prove stale and out-of-region projects are excluded, since()
honours its cutoff, and paging covers every project.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…or more

Disabling every filter also skipped the JSON decode of collection metadata,
and the shared collection cache then handed HTTP a string where it expected
attributes. Skip the named project subqueries as Source\Database does, and
let an edition extend the list through a protected hook, as ScheduleFunctions
does for spreadWindow.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Keep main's build timeout plumbing and the Utopia\Command refactor, and
drop the root directory canonicalization this branch had added: the
orchestrator cleans an artifact subdir on every extraction path, and the
sparse-checkout pattern is the vcs adapter's to resolve.
appwrite#13697 landed the Google- and Apple-shaped claim tests on the same tail
of AccountCustomClientTest, which is the only conflict. Both sets of
tests are kept: main's two shape tests and its isMockOAuth2Photo helper,
followed by this branch's testCreateIdTokenSessionStoresIdToken and its
findMockIdentity / decodeJwtPayload helpers.

2.2.0 maps to V25 in Migration.php, so the providerIdToken attribute
stays in the migration it was added to.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PHPStan flagged the assertion as dead: base64_decode() only returns false
in strict mode, so asserting the non-strict result is a string always
held. Decode strictly and assert against false, which also stops a
payload that is not really base64url from being silently scrubbed into
something that decodes to nothing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Remove the project-database executions schema now that ClickHouse is the
only execution store. Keep execution and site-log query validation
independent from the physical MySQL collection definition.

Co-authored-by: Torsten Dittmann <[email protected]>
feat(releases): a nightly channel for self-hosting
…s-utopia-scheduler-1d1c1e

feat(stats-resources): spread project counts across the interval with the scheduler
…ions-schema-048b

fix(executions): stop creating MySQL collection
Adds a `password-pwned` project policy, disabled by default, that checks
new passwords against the Have I Been Pwned range API using k-anonymity.
Only the first five characters of the SHA-1 hash leave the server.

When enabled, breached passwords are rejected with `password_pwned` on
account create, account password update, account recovery update, users
create, and users password update. Hashed imports are unaffected. The
check fails open when the service is unreachable.

The endpoint is configurable via `_APP_PWNED_PASSWORDS_ENDPOINT`; the dev
and CI `.env` points it at a new mock range route so automated tests never
contact the real service.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
git-subtree-dir: packages/agents
git-subtree-mainline: 256b080
git-subtree-split: c978583
Appwrite becomes the home of every utopia-php library, loads each one directly from packages/<name> through the root autoload, and keeps mirroring them to Packagist for other consumers. The RFC records the target shape, the standard package layout, version gaps, the phase plan and open questions.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
First slice of rfc/monorepo.md, proving package for the tooling. agents
sits under packages/agents in the standard shape (Utopia\Agents\ => src/,
Utopia\Agents\Tests\ => tests/, tests/e2e/ for the suites that need a
provider key or a service) and the root composer.json autoloads it;
utopia-php/agents leaves require. It was imported from its main branch with
history (the preceding subtree merge).

Root wiring: a `packages` PHPUnit suite over the unit tiers, COPY ./packages
in the Dockerfile (the optimised autoloader falls back to PSR-4 for classes
outside its class map, so no re-dump is needed), dockerignore entries, and
AGENTS.md pointing at packages/.

Packages are analysed under their own phpstan.neon with the root binary, not
by the root config: at Appwrite's level 4 their level-max ignore comments
become errors.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…verage

Extends the `password-pwned` policy with options, all optional on update
and preserving the others when omitted:

- `forceReset` (default false): when true, signing in with a breached
  password fails with `user_password_reset_required` until it is reset.
- `failClosed` (default true): reject the password with the new
  `general_pwned_passwords_unavailable` (503) when the breach service
  cannot be reached; when false the check is skipped.
- `threshold` (default 1): minimum breach count before rejection.
- `endpoint` (default empty): project-level range API endpoint, falling
  back to `_APP_PWNED_PASSWORDS_ENDPOINT`, then the public service.
  Validated as a public http(s) URL like webhook URLs.

The validator is now built from the policy and registered as the
`pwnedPasswords` request resource, caching range responses per prefix
and endpoint for an hour through the cache library.

Anonymous accounts setting their first password through the email or
phone update endpoints now go through the same policies as account
creation: strength, dictionary, personal data, pwned, and history.
Existing passwords are only verified, never re-validated.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Phase 1 tooling from rfc/monorepo.md, ported from utopia-php/monorepo.
bin/monorepo keeps list, absorb, split, release, validate, check, test and
dependents; graph and benchmark are dropped. Mirrors stay under utopia-php,
every link back now points at packages/<name> here. validate enforces the
standard package shape (one Utopia\<Ns>\ prefix over src/, its Tests\
prefix over tests/, no lock, no hoisted QA, a phpstan.neon, mirror.yml)
and the root autoload wiring; the new autoload subcommand regenerates the
root entries from the package manifests. check analyses each package under
its own phpstan.neon with the root binaries, Rector first so --fix leaves
formatted output.

split.yml, split-dev.yml and mirror-redirect.yml move over with pinned
actions. ci.yml validates packages in the checks job, runs the packages
PHPUnit suite in the unit job (packages/ is mounted like tests/), and gains
the changed-package matrix: diff against the base ref, expand through
dependents, check and test each package, linked for dependents.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Add the mirror.yml that redirects pull requests and issues opened on
utopia-php/agents back here, the read-only-mirror banner under the README
H1, and drop what the mirror no longer needs: the issue templates, the
docker-compose.yml that referenced a Dockerfile removed with the shape
change (agents defines no e2e tier), and its .env.example.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ched

Adds a nullable `passwordPwned` boolean to the users collection, with an
index, and exposes it on the User and Account models. It is null until a
password has been checked by the pwned policy, false when the last check
was clean, and true when the last check found the password in a breach.

The flag is written wherever the policy checks a password: account and
user creation, password updates, recovery, anonymous conversions, and
password sign-in. Sign-in records the outcome whether or not a reset is
forced, and an unreachable service leaves the stored value untouched.
Setting a password without a check, clearing it, or importing a hash
resets the flag to null.

Users can be listed by the flag through `Query::equal` and `isNull`.
The attribute and index are created by the V25 migration.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The project policy key, validator, and resource keep their names; only
the users collection attribute, its index, the model rule, the query
whitelist, and the local variables change.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…-scheme

fix(console): link the new console everywhere and drop the legacy /console scheme
Adds a `sessions` option to the password pwned policy, off by default,
controlling whether passwords are checked when a session is created.
`forceReset` now only applies when sessions are checked, giving three
sign-in modes: no check, check and record, check and block.

Flips the policy defaults so `enabled` is true. New and existing
projects reject breached passwords out of the box, while sign-in checks
stay opt-in.

The mock range endpoint reports distinctive fixtures now, so enabling
the policy by default cannot collide with passwords other suites use.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review feedback: the validator tests mirrored the URL format, HTTP
method, an internal header, and the class's own endpoint constant, so
they could never fail meaningfully and made harmless transport changes
require synchronised rewrites.

They now assert what the guarantee actually is: neither the password,
its full hash, nor the identifying suffix reaches the service, and only
the five character prefix does. Endpoint precedence is asserted with
values the test owns rather than the source constant, and the fetch
double records the URLs that left the server rather than how they were
transported.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review feedback: with the policy now enabled by default, defaulting
`failClosed` to true meant any project that had never configured the
policy would reject password creation, updates and recovery with a 503
whenever the breach service was unreachable.

`failClosed` now defaults to false, so an outage skips the check and
leaves the recorded state untouched. Rejecting on outage stays available
by setting it to true.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
ArnabChatterjee20k and others added 26 commits September 21, 2026 11:16
Add e2e coverage for reply-to fields: persistence and validation on
create/update, and the delivered reply-to header over SMTP.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Accept an empty string for replyToEmail so a draft can drop a custom
reply-to and fall back to the provider or sender, matching the worker's
empty-value handling.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Assert an empty string clears the reply-to, and check both the address
and display name on the delivered mail.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Text defaults to a minimum length of one, so an empty replyToName was
rejected. Use Text(128, 0) as the provider create actions do, letting an
empty string clear the custom reply-to name.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The membership privacy policy is documented as controlling what members
can see about *other* members, but it was applied to every membership in
the list, including the requester's own. New projects are created with
`membershipsUserId` disabled, so a standard user listing team
memberships got an empty `userId` on every row - including their own -
and could no longer tell which membership was theirs. That also left
them unable to leave a team, since removing a membership needs its ID.

Treat the requester's own membership like a privileged read in both
`GET /v1/teams/:teamId/memberships` and
`GET /v1/teams/:teamId/memberships/:membershipId`, matching how
`Memberships/Delete.php` and `Memberships/Update.php` already identify
the caller's own membership. None of these fields are secret from the
member anyway - `GET /v1/account` returns all of them.

Fixes appwrite#13767
…-messaging

Feat add reply params messaging
…abels

ci: select runners by preset instead of a machine spec
Updating a push target to an identifier already registered on another target hit the unique index on targets and surfaced as an unhandled 500 (Sentry CLOUD-3QX3). Create push target already maps this to USER_TARGET_ALREADY_EXISTS; the update path now does the same.
…able

chore: mark the React Native SDK stable
The phone, email and magic URL token endpoints create a user when no user matches the identifier, but never caught the unique-index failure when the caller supplied a userId that already belongs to another user. That surfaced as an unhandled 500 (Sentry CLOUD-3QYD, 5.7k events). Map it to USER_ALREADY_EXISTS like the other user-creating endpoints.
…y-self

fix(teams): exempt a member's own membership from the privacy policy
The deletes worker removes the repository row after the resource, so a push arriving in between resolves an empty resource, queries deployments by a null sequence and fails the whole webhook with a 500 (Sentry CLOUD-3QWM). Skip that repository and keep handling the rest.
Regenerated with `composer update utopia-php/cdn` now that the tag exists.
Only utopia-php/cdn moves: 0.0.11 -> 0.0.12 at 762f1a9.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
main moved on since this branch was cut and composer.lock conflicted.
Resolved by taking main's lock and re-running `composer update utopia-php/cdn`,
so the branch differs from main by the pin and its lock entry only.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ation-after-api-check

fix(certificates): do not verify DNS again for a job the endpoint just verified
…-0.0.12

chore(deps): bump utopia-php/cdn to 0.0.12
…e-duplicate

fix: return 409 when a push target update reuses an existing identifier
…ed-resource

fix: skip VCS webhook repositories whose function or site was deleted
…cate-user

fix: return 409 when a token request reuses an existing user ID
…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)
@Meldiron
Meldiron force-pushed the fix/11647-file-encryption-property branch from 12d2e05 to cf9a0a1 Compare September 21, 2026 11:03
@Meldiron

Copy link
Copy Markdown
Contributor

Closing in favour of #12405.

Both PRs are open from the same head branch (fix/11647-file-encryption-property) — this one targeted 1.9.x, #12405 targeted main. Since a branch can only have one PR per base, and we're consolidating onto main, I rebased the branch onto main and let #12405 carry it. That PR is now a clean 1-file, +6/-2 diff and mergeable.

No work is lost — #12405 has exactly the change from this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File encryption property is missing