Skip to content

fix(databases): scope list cache to collection permissions and gate inline encryption - #14791

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/databases-list-cache-and-inline-encrypt
Oct 22, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/databases-list-cache-and-inline-encrypt

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

What

  • List cache key: the cache field for list documents / rows now includes the collection's $permissions and documentSecurity. Changing either takes effect on the next list call instead of after the cached TTL, without needing purge=true.
  • Inline encrypted attributes / columns: creating a collection or table with inline definitions that carry the encrypt filter now applies the same checks as the dedicated string endpoints: the databasesAllowEncrypt plan gate (no-op without a plan, as on self-hosted) and the APP_DATABASE_ENCRYPT_SIZE_MIN minimum size. The half-created collection is removed on rejection, as with the other inline validation failures. plan is now injected into the legacy, TablesDB and DocumentsDB create actions.

Tests

  • DatabasesBase::testListDocumentsCacheBustedByPermissionChange: miss, hit, then a permissions-only update gives a miss, and a documentSecurity-only update gives a miss.
  • DatabasesBase::testCreateCollectionInlineEncryptedStringTooSmall: an inline encrypted string below the minimum size returns 400 and no collection is left behind.
  • The plan gate has no e2e coverage here because self-hosted test projects have no plan; it mirrors the existing check in Attributes/String/Create.php.

E2E was not run locally (shared machine); relying on the CI e2e lanes. Pint, PHPStan and Rector pass for the touched files.

Related: appwrite-labs/cloud#6666

…nline encryption

Cached list responses were keyed on schema, roles and queries only, so a change to collection permissions or documentSecurity kept serving the old entries until the TTL expired. Fold both into the cache field.

Inline attributes and columns could carry the encrypt filter without the plan check or minimum size the dedicated string endpoints enforce. Apply the same checks when creating a collection or table with inline definitions.
@luxor-code-review

luxor-code-review Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high

💬 Inline comments (1)

  • 🟠 Non-canonical filters shapes bypass encrypt gates — Create.php:165

The change introduces an encrypt attribute filter with plan gating and size validation at collection-create time, plus compensating cleanup when validation fails, and extends the list-cache field hash to include collection permissions and documentSecurity so authorization changes take effect immediately. E2E coverage in DatabasesBase exercises the new paths.

Files Change
src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php Adds shared encrypt detection and list-cache hash inputs (permissions, documentSecurity) to the base action
.../Databases/Collections/Create.php, .../DocumentsDB/Collections/Create.php, .../TablesDB/Tables/Create.php Gate encrypt columns behind plan entitlement, validate size, and clean up partially created collections on failure
tests/e2e/Services/Databases/DatabasesBase.php Adds e2e coverage for encrypt gating and cache busting behavior

Reviewed commit: 006fa8f

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 22, 2026
@ghost

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

List-response cache keys now include collection permissions and document security, so changes to either invalidate cached responses. Inline encrypted attributes and columns receive the plan and minimum-size checks used by dedicated endpoints, with rejected collection creation cleaned up; E2E coverage exercises permission-sensitive cache misses and undersized encrypted definitions.

Latest changes: The newest commits make inline encryption detection recognize keyed filter maps using the same loose matching as attribute responses, and add an E2E regression for that input shape.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 5
File Change
src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php Adds permissions and document security to list-response cache-field hashing.
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php Injects plan data and applies encryption plan and minimum-size validation to inline definitions, including keyed filter maps.
src/Appwrite/Platform/Modules/Databases/Http/DocumentsDB/Collections/Create.php Passes plan data into the shared collection creation action.
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Tables/Create.php Passes plan data into the shared table creation action.
tests/e2e/Services/Databases/DatabasesBase.php Adds E2E coverage for permission-sensitive list-cache misses and inline encrypted definitions that are too small, including keyed filters.

Reviewed the commits since 006fa8f · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Tier S · Looks good to merge. Summary

@luxor-code-review luxor-code-review Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR adds encrypted string attribute/column support gated by plan entitlement in collection creation, and busts the list cache on permission/documentSecurity changes across the Databases, DocumentsDB, and TablesDB Create actions.

Key findings

  • 🟠 Non-canonical filters shapes bypass encrypt gates — Create.php:165

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/databases-list-cache-and-inline-encrypt (after).

Metric Before After Change
🚀 Requests/sec 200.74 202.34 ⚪ +0.8%
⏱️ Latency P50 86.39 ms 87.08 ms ⚪ +0.8%
⏱️ Latency P95 201.76 ms 200.11 ms ⚪ -0.8%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 87.08 200.11 12,540 202.34 -1.65
Account 158.83 300.75 660 11.32 +20.92
TablesDB 84.67 152.89 6,820 111.95 -10.86
Storage 79.42 195.61 3,300 56.3 +1.6
Functions 119 233.02 1,760 30.91 +12.23

Top API waits (after)

API request Max wait (ms)
account.name.update 421.16
storage.buckets.create 406.29
functions.create 387.49
account.prefs.update 387.03
functions.variables.create 386.67

The attributes validator accepts filters that are not a plain list of strings, and the attribute response filter reads encrypt with a loose match, so the inline checks have to read it the same way to apply to every accepted shape.
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

6 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (3)
  • php.appwrite.secret-compare-timing (1)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@ChiragAgg5k
ChiragAgg5k merged commit db6ea18 into main Oct 22, 2026
41 checks passed
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…nline encryption (backport #14791)

The list cache key ignored collection permissions and documentSecurity, so a permission change kept serving cached lists until the TTL ran out. Inline encrypted attributes on create collection/table skipped the plan gate and minimum size the dedicated string endpoints apply.

(cherry picked from commit db6ea18)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…nline encryption (backport #14791)

The list cache key ignored collection permissions and documentSecurity, so a permission change kept serving cached lists until the TTL ran out. Inline encrypted attributes on create collection/table skipped the plan gate and minimum size the dedicated string endpoints apply.

(cherry picked from commit db6ea18)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…nline encryption (backport #14791)

The list cache key ignored collection permissions and documentSecurity, so a permission change kept serving cached lists until the TTL ran out. Inline encrypted attributes on create collection/table skipped the plan gate and minimum size the dedicated string endpoints apply.

(cherry picked from commit db6ea18)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…che-and-inline-encrypt

fix(databases): scope list cache to collection permissions and gate inline encryption

(cherry picked from commit db6ea18)
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.

1 participant