Skip to content

fix(migrations): check source key scopes for DocumentsDB and VectorsDB - #14868

Merged
abnegate merged 2 commits into
mainfrom
fix/migration-source-scopes
Oct 23, 2026
Merged

abnegate merged 2 commits into
mainfrom
fix/migration-source-scopes

Conversation

@abnegate

Copy link
Copy Markdown
Member

What does this PR do?

For a migration from another project on the same cluster, the source key is now checked against the DocumentsDB and VectorsDB APIs whenever those families are requested, not only TablesDB.

Test Plan

Three new e2e tests in tests/e2e/Services/Migrations/MigrationsBase.php (TablesDB-only key for DocumentsDB, for VectorsDB, and a correctly scoped key). Migrations e2e 83/83 with _APP_DOCUMENTSDB and _APP_VECTORSDB enabled. Lint, PHPStan and Rector are clean.

Related PRs and Issues

  • None

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

🤖 Generated with Claude Code

For a migration from another project on the same cluster, the source key is now checked against the DocumentsDB and VectorsDB APIs whenever those families are requested, not only TablesDB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 2 medium

💬 Inline comments (2)

  • 🟡 Unconditional TablesDB->list() probe rejects documentsdb/vectorsdb-scoped keys — Migrations.php:377
  • 🟡 Scope probe skips documentsdb.indexes.read / vectorsdb.indexes.read — Migrations.php:421

The change adds per-family scope probes for DocumentsDB and VectorsDB in authenticateSource(), including a new probeCollectionScopes() helper, and adds e2e regression tests for the reject and accept paths.

Files Change
src/Appwrite/Platform/Workers/Migrations.php Adds DocumentsDB/VectorsDB API probes and a probeCollectionScopes() helper to authenticateSource()
tests/e2e/Services/Migrations/MigrationsBase.php Adds e2e tests asserting scoped-key rejection and acceptance for the new database families

Reviewed commit: 8e7a306

@ghost

ghost commented Oct 23, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The family-specific probes align with the requested resources, and the new e2e coverage verifies index-scope enforcement.

The migration worker validates source API keys against each requested database family and its resource scopes before reading data directly. E2E coverage verifies rejection of cross-family or missing scopes and successful migration with a correctly scoped DocumentsDB key.

Latest changes: The new commits gate TablesDB probes on requested TablesDB resources, add DocumentsDB and VectorsDB index-scope probes, and test rejection when the DocumentsDB index scope is missing.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Platform/Workers/Migrations.php Validates requested database family scopes, including index access for DocumentsDB and VectorsDB.
tests/e2e/Services/Migrations/MigrationsBase.php Covers family-specific key rejection, missing DocumentsDB index scope, and successful migration with scoped access.

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

@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 extends the migrations worker's source-authentication scope probing to the DocumentsDB and VectorsDB database families with e2e coverage, but keeps an unconditional TablesDB probe that rejects narrowly scoped keys and misses the families' dedicated index scopes.

Key findings

  • 🟡 Unconditional TablesDB->list() probe rejects documentsdb/vectorsdb-scoped keys — Migrations.php:377
  • 🟡 Scope probe skips documentsdb.indexes.read / vectorsdb.indexes.read — Migrations.php:421

@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

@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.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/migration-source-scopes (after).

Metric Before After Change
🚀 Requests/sec 201.8 210.15 ⚪ +4.1%
⏱️ Latency P50 85.55 ms 81.27 ms ⚪ -5%
⏱️ Latency P95 196.77 ms 194.84 ms ⚪ -1%
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 81.27 194.84 13,167 210.15 -1.93
Account 168.01 336.68 693 11.5 +56.93
TablesDB 79.6 147.44 7,161 116.74 -9.52
Storage 72.45 173.73 3,465 58.23 -8.31
Functions 113.43 217.01 1,848 31.75 -4.31

Top API waits (after)

API request Max wait (ms)
account.name.update 486.9
account.get 434.18
tablesdb.rows.create 418.55
account.prefs.update 396.22
functions.delete 394.42

… index scopes

A DocumentsDB or VectorsDB migration no longer needs TablesDB scopes, since TablesDB databases are only exported when TYPE_DATABASE is requested. Index exports for DocumentsDB and VectorsDB now require that family's indexes read scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abnegate
abnegate merged commit 67d57dc into main Oct 23, 2026
38 checks passed
@abnegate
abnegate deleted the fix/migration-source-scopes branch October 23, 2026 02:05
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…B (backport #14868)

Ported with the 1.9.x raw client probes. The TablesDB probe keeps its 1.9.x condition, and the tests use the 1.9.x scope names, where DocumentsDB and VectorsDB share the collections and documents scopes.

(cherry picked from commit 67d57dc)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…scopes

fix(migrations): check source key scopes for DocumentsDB and VectorsDB

(cherry picked from commit 67d57dc)
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