Skip to content

fix(migrations): complete 2.6 upgrades and preserve new fields - #14737

Merged
ChiragAgg5k merged 2 commits into
2.6.xfrom
fix/release-2.6-migration-sync
Oct 21, 2026
Merged

ChiragAgg5k merged 2 commits into
2.6.xfrom
fix/release-2.6-migration-sync

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Problem

The 2.6.0 release gates found two upgrade/transfer gaps after #14730 merged:

  • Upgrading a real 2.5.0 project stops in V25's document pass because seven new video collections have not been created. This happens even with the self-hosted video APIs disabled.
  • The locked PHP SDK and migration resources omit 2.6's descriptions and bucket stripMetadata, so project transfers lose those settings.

Changes

Create the new video collections before migrating their documents, with the existing idempotent collection helper. Update the PHP SDK to 32.0.0 and carry descriptions and metadata stripping through resource serialization, the Appwrite source, and SDK/direct-database destinations. Include descriptions in schema overwrite comparisons and preserve the source side separately from inverse relationship metadata. Carry the SDK's new direct email recipient parameter from existing message data.

Extend the existing migration E2E cases to verify destination descriptions and bucket metadata settings through public APIs. Update memory schemas to the actual 2.6 metadata schema. Seventeen existing PHPStan baseline patterns follow the extended array type spelling; no baseline entries or counts were added.

Validation

  • Migration package unit suite: 186 tests, 935 assertions passed.
  • Migration package PHPStan: zero errors at its configured level and existing baseline.
  • V25 regression observed failing with Collection not found before the production fix; full V25 unit file passes after it (8 tests, 39 assertions), including a persisted video record across two migration runs.
  • Isolated PostgreSQL upgrade from 2.5.0: the original migration failure reproduced; with the fix, migration completed twice and public API reads/writes preserved the seeded console session, project/key, users/teams, indexed permissioned multilingual rows, and encrypted file bytes.
  • Pint, Rector dry run, monorepo shape validation and Composer audit pass.
  • Full server PHPStan analysis passes. Local unit suite: 2,006 tests, 21,975 assertions passed.
  • Fresh production configuration: seeded accounts, teams, database records, index, permissions and exact encrypted file bytes pass API reads and writes.
  • Extended transfer E2E passes against both local database reads and remote SDK/API reads: 8 tests and 354 assertions per path, covering descriptions for databases, tables/columns/indexes, storage, functions, variables, keys, webhooks and topics, plus bucket metadata stripping. The two database/table description assertions first failed against the incomplete reader handling, then passed after normalizing local Documents to arrays.
  • CI is being completed before release publication.

Required for 2.6.0; publish only after this fix is merged and the final release SHA is validated.

Related: appwrite-labs/cloud#6671

Final production candidate 2bf244a also passes fresh and seeded-upgrade API reads/writes, both gateway HTTP200 checks, self-hosted Console sign-in rendering, two migration runs, and cURL/Swoole rejection of both compromised certificate chains. SDK32 model hydration was checked with description and stripMetadata missing: all seven source model types initialize these new fields to the compatible empty/false defaults, so older API responses do not leave these typed properties uninitialized. The review finding about direct database Documents is fixed in 2bf244a; both source paths pass their API transfer tests.

@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • 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.

@luxor-code-review

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

Copy link
Copy Markdown

Review complete. 🟡 2 medium

💬 Inline comments (2)

  • 🟡 is_array guard silently drops descriptions on database source — Appwrite.php:1245
  • 🟡 Unguarded SDK model description/stripMetadata reads abort migration — Appwrite.php:1639
🧹 Nitpicks (2) — 🟢 2 low
  • 🟢 Destination index status never asserted as available (MigrationsBase.php:906) — The destination-side verification of the migrated index only asserts HTTP 200 and description (tests/e2e/Services/Migrations/MigrationsBase.php:906).
  • 🟢 ?? '' fallbacks pass explicit null descriptions through (Database.php:60) — The Database-family fromArray methods use $array['description'] ?? '' (packages/migration/src/Resources/Database/Database.php:60), which only falls back when the key is absent — an explicit "description": null in a dump passes null into the typed setDescription(string) setter and throws a TypeError.

The change threads a description field through the entire migration pipeline so column/table/index/database metadata descriptions survive transfers between Appwrite instances. The migration resource base class gains a description property with fluent accessors, and every resource subclass (Attribute, Column variants, Index, Table, Collection, Database, Bucket, Func, Site, Topic, Webhook, ApiKey, EnvVar, ProjectVariable) now serializes, deserializes, and spec-matches on it with '' defaults for older dumps. The destination adapter writes descriptions into destination documents and includes them in the four specMatches comparators, and buckets additionally gain a stripMetadata constructor flag honored at import time. The SDK constraint moves to appwrite/appwrite ^32.0.0 in both composer.json files (lockfile already at 32.0.0), which the new named-argument call sites require. Tests: fixture schemas gain description(1024) attributes, unit/CLI destination tests updated, the V25 in-place migration teaches itself the new field, and the e2e Migrations suite asserts description round-trip plus a new index resource.

Files Change
packages/migration/src/Resource.php, src/Resources/** Adds description property, accessors, and fromArray/jsonSerialize wiring across all resource classes (plus stripMetadata on Bucket).
packages/migration/src/Sources/Appwrite.php, Destinations/Appwrite.php Exports descriptions at the source, imports and spec-matches them at the destination, including sparse in-place updates.
composer.json, packages/migration/composer.json, phpstan-baseline.neon Bumps appwrite/appwrite to ^32.0.0 and adjusts the baseline.
src/Appwrite/Migration/Version/V25.php, tests/unit/Migration/Version/V25Test.php Teaches the V25 in-place migration the new description field with unit coverage.
packages/migration/tests/**, tests/e2e/Services/Migrations/MigrationsBase.php Fixture schemas gain description(1024), destination tests updated, e2e asserts description round-trip and index availability.

Reviewed commit: e07ecb8

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

ghost commented Oct 21, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The earlier direct-database description gap is fixed, and the incremental changes introduce no remaining defect.

The migration package now targets Appwrite SDK 32 and carries 2.6 descriptions and bucket metadata-stripping settings through resource serialization, source reads, and SDK/direct-database destinations. V25 creates the new video collections before migrating their documents, and the migration tests cover upgrade and transfer behavior. The latest updates also normalize direct-database Documents in the source reader and improve migration failure diagnostics in the E2E helper.

Latest changes: The new commits convert direct-database Documents for databases, tables, and indexes to arrays before source serialization, fixing description preservation on that path, and include the migration response message in E2E assertion failures.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 6
File Change
composer.json, composer.lock, packages/migration/composer.json, packages/migration/phpstan-baseline.neon Update the migration SDK dependency and align existing PHPStan baseline patterns with the extended array type spelling.
packages/migration/src/Resource.php, packages/migration/src/Resources/** Add descriptions and bucket stripMetadata to migration resource serialization.
packages/migration/src/Sources/Appwrite.php, packages/migration/src/Sources/Appwrite/Reader/** Read the 2.6 fields from Appwrite sources, including normalizing direct-database Documents for databases, tables, and indexes.
packages/migration/src/Destinations/Appwrite.php Preserve descriptions and bucket metadata settings in SDK and direct-database destination writes and overwrite comparisons.
src/Appwrite/Migration/Version/V25.php, tests/unit/Migration/Version/V25Test.php Create the new video collections before migrating documents and cover repeat migration with existing video data.
packages/migration/tests/**, tests/e2e/Services/Migrations/MigrationsBase.php Update migration test schemas and cover field transfer behavior; include server response messages in migration-start assertion failures.
✅ Fixed since the last review · 1
  • Read descriptions from direct-database Documents · packages/migration/src/Sources/Appwrite.php:1245

Reviewed the commits since e07ecb8 · 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 A · See the inline comments. 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 description (and a stripMetadata bucket flag) round-tripping through the migration package — source export, resource serialization, destination import — bumps the appwrite SDK to ^32, and extends the V25 migration and e2e tests accordingly.

Key findings

  • 🟡 is_array guard silently drops descriptions on database source — Appwrite.php:1245
  • 🟡 Unguarded SDK model description/stripMetadata reads abort migration — Appwrite.php:1639

$newDatabase = self::getDatabase($databaseFamilyType, [
'id' => $database['$id'],
'name' => $database['name'],
'description' => \is_array($database) && \is_string($database['description'] ?? null) ? $database['description'] : '',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 bug · medium

is_array guard silently drops descriptions on database source

The new description guards require \is_array($database), but when the source is SOURCE_DATABASE the reader returns Utopia Document objects (packages/migration/src/Sources/Appwrite/Reader/Database.php:173), which support ArrayAccess but are not arrays. The is_array check therefore always fails and the description is silently reset to '' for every database, table, index and column migrated from a database source (packages/migration/src/Sources/Appwrite.php:1245). The same wrong guard appears in exportEntities, exportIndexes and getColumn.

📋 Prompt for AI Agents

In packages/migration/src/Sources/Appwrite.php at line 1245 (exportDatabases), line 1311 (exportEntities), line 1436 (exportIndexes) and line 3669 (getColumn), change the description guard from \is_array($x) && \is_string($x['description'] ?? null) ? $x['description'] : '' to just \is_string($x['description'] ?? null) ? $x['description'] : ''. The source values are either plain arrays (API reader) or Utopia Database Document objects (database reader), and Document supports ArrayAccess, so the is_array() clause wrongly excludes Documents and silently drops descriptions in SOURCE_DATABASE migrations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 2bf244a. Database, table, and index exports now normalize Utopia Documents with getArrayCopy() before the array guards; getColumn() already normalizes Documents. The transfer E2E tests initially reproduced lost descriptions, then passed with this fix: 8 tests / 354 assertions for the direct-database source, and again for the remote API source, checking destination metadata through public APIs.

Comment on lines +1639 to +1640
stripMetadata: $bucket->stripMetadata,
))->setDescription($bucket->description);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 bug · medium

Unguarded SDK model description/stripMetadata reads abort migration

The new export paths read description and stripMetadata straight off SDK model objects with no null guard, e.g. setDescription($bucket->description) and stripMetadata: $bucket->stripMetadata (packages/migration/src/Sources/Appwrite.php:1639). The Bucket constructor declares a non-nullable bool $stripMetadata and Resource::setDescription() declares a strict string (packages/migration/src/Resource.php:350), so when the source server predates these fields the migration aborts with a TypeError mid-export. The PR itself guards the hazard everywhere else — every array path uses \is_string(... ?? null) and the adjacent bucket line still uses $bucket->transformations ?? false — leaving these live-model reads the only unguarded path into the same fields.

📋 Prompt for AI Agents

In packages/migration/src/Sources/Appwrite.php, harden every unguarded description/stripMetadata read so cross-version migration from servers that predate these fields does not fatal: at lines 1639-1640 change to stripMetadata: $bucket->stripMetadata ?? false and ->setDescription(\is_string($bucket->description ?? null) ? $bucket->description : ''); apply the same \is_string($x->description ?? null) ? $x->description : '' pattern at lines 2251, 2302, 2366, 2378, 2789, 2957, 2969 and 3387 (the $variable, $webhook, $function, $var, $topic, $site, $var and $key model reads). Resource::setDescription() requires a strict string, so a null from an older source server currently raises a TypeError and aborts the whole migration run.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This does not reproduce with the pinned SDK 32.0.0. Its Models::from() factories initialize fields missing from older server responses before constructing typed models: description defaults to an empty string, and Bucket::from() defaults stripMetadata to false. I verified responses omitting these fields against all seven affected factories: Bucket, FunctionModel, Site, Variable, Topic, Key, and Webhook. The migration receives initialized model properties, so these reads do not introduce the reported TypeError for older servers. No additional SDK release or fallback guards are needed for this case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The user's claim is that SDK 32.0.0's Models::from() factories initialize missing fields before constructing typed models, so description defaults to '' and stripMetadata defaults to false. This is a reasonable defense-in-depth argument, but the finding is about the source code in this PR — not about SDK behavior. Let me check the diff more carefully.

Looking at the current diff for packages/migration/src/Sources/Appwrite.php, the bucket path still shows:

  • stripMetadata: $bucket->stripMetadata (no ?? false)
  • ->setDescription($bucket->description) (no null guard)

And for all other SDK model reads ($variable->description, $webhook->description, $function->description, $var->description, $topic->description, $site->description, $key->description), the diff shows these are passed directly without guards.

The claim relies entirely on SDK-level initialization guarantees. While SDK 32.0.0 may initialize these fields, the code in this PR does not enforce that behavior at the migration layer. If the SDK is ever updated, downgraded, or used against a truly unexpected server version outside the tested matrix, the TypeError risk remains. The PR's own pattern for array paths (\is_string($x['description'] ?? null) ? $x['description'] : '') is the correct defensive approach, and the live-model paths are inconsistent with it.

The fix has not been applied in the diff — the guards recommended in the original finding are absent.

@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

✨ Benchmark results

Comparing 2.6.x (before) → fix/release-2.6-migration-sync (after).

Metric Before After Change
🚀 Requests/sec 198.65 206.25 ⚪ +3.8%
⏱️ Latency P50 84.09 ms 83.83 ms ⚪ -0.3%
⏱️ Latency P95 211.74 ms 200.02 ms 🟢 -5.5%
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 83.83 200.02 12,711 206.25 -11.72
Account 154.98 286.87 669 11.09 -20.75
TablesDB 79.84 144.47 6,913 113.68 -17.63
Storage 80.8 193.31 3,345 56.8 +7.96
Functions 119.73 238.04 1,784 31.04 -19.22

Top API waits (after)

API request Max wait (ms)
storage.buckets.create 477.57
account.prefs.update 445.65
account.name.update 421.44
functions.variables.create 399.84
functions.variables.update 381.99

@ChiragAgg5k
ChiragAgg5k merged commit 796049a into 2.6.x Oct 21, 2026
240 of 241 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/release-2.6-migration-sync branch October 21, 2026 15:59
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