Skip to content

fix(migration): repair missing email metadata attributes in V25 - #13820

Merged
HarshMN2345 merged 6 commits into
mainfrom
fix/issue-11906
Sep 23, 2026
Merged

HarshMN2345 merged 6 commits into
mainfrom
fix/issue-11906

Conversation

@HarshMN2345

Copy link
Copy Markdown
Member

What does this PR do?

The five email metadata attributes on the users collection — emailCanonical, emailIsFree, emailIsDisposable, emailIsCorporate and emailIsCanonical — are created only by V23, inside a try/catch that swallows failure with a warning. V25's users arm creates only passwordPwned, and the migrate task runs a single version class, so an install whose V23 users step failed ends up with a users collection missing all five.

Creates and the email-update paths put those keys in the payload, so on such an install they fail with Invalid document structure: Unknown attribute: "emailCanonical".

This creates the attributes from the collection config in V25's users arm — the same repair already applied to the functions and sites arms for the provider attributes. createAttributesFromCollection() skips ids the collection already has, so it is a no-op on healthy installs.

Test Plan

  • composer lint src/Appwrite/Migration/Version/V25.php → {"tool":"pint","result":"passed"}
  • Confirmed against Migration::createAttributesFromCollection that existing attribute ids are filtered out, so re-running is idempotent.
  • Confirmed the same repair shape is already used in V25's functions and sites arms.

Not run: the migration was not executed against a real seeded stack — that needs a 1.8.x install upgraded with volumes retained, which was not available here. Worth exercising on the standard upgrade gate before release.

Related PRs and Issues

Note for the reporter: Migration::$versions maps 1.9.0–1.9.5 to V24, so a target of exactly 1.9.0 does not pick this repair up. Upgrading to 1.9.6 or any 2.x target does.

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? — no metadata change

The five email metadata attributes on the users collection --
emailCanonical, emailIsFree, emailIsDisposable, emailIsCorporate and
emailIsCanonical -- are created only by V23, inside a try/catch that
swallows failure with a warning. V25's users arm creates only
passwordPwned, and the migrate task runs a single version class, so an
install whose V23 users step failed, or one that upgraded straight from
1.8.x, ends up with a users collection missing all five.

Every user write puts those keys in the create payload, so such an
install fails all of them with Invalid document structure: Unknown
attribute: "emailCanonical".

Create the attributes from the collection config in V25's users arm, the
same repair already applied to the functions and sites arms for the
provider attributes. createAttributesFromCollection() skips ids the
collection already has, so this is a no-op on healthy installs.
@greptile-apps

greptile-apps Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The production repair appears safe to merge; the only remaining concern is non-blocking regression-coverage completeness.

Fix All in Claude CodeFindings

  1. P2 Missing upgrade regression coverage ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Migration/Version/V25.php:266-270
This schema repair has no behavioral test for the failure it fixes. Existing V25 coverage exercises only the functions and sites repairs, while failures here are reduced to warnings and can leave user writes broken. Add an upgrade test that begins with the affected legacy users schema, runs the migration twice, and verifies through a user create or update operation that writes succeed. Avoid merely asserting that the five configured attribute IDs exist, since that would duplicate implementation details rather than test observable behavior.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

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

Summary

This PR repairs V25 upgrades whose users collection is missing the five email-metadata attributes originally introduced by V23.

  • Recreates only missing configured attributes, preserving healthy installations.
  • Adds regression coverage that runs the public migration entrypoint against a legacy users schema and verifies a user carrying email metadata can be persisted.
  • The regression now tests observable behavior instead of invoking private migration internals.

Reviews (6) · Last reviewed commit: "Merge branch 'main' into fix/issue-11906"

Comment on lines +266 to +270
try {
$this->createAttributesFromCollection($this->dbForProject, $id, $attributes);
} catch (Throwable $th) {
Console::warning('Failed to create attributes "' . \implode(', ', $attributes) . "\" in collection {$id}: {$th->getMessage()}");
}

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.

P2 Missing upgrade regression coverage

This schema repair has no behavioral test for the failure it fixes. Existing V25 coverage exercises only the functions and sites repairs, while failures here are reduced to warnings and can leave user writes broken. Add an upgrade test that begins with the affected legacy users schema, runs the migration twice, and verifies through a user create or update operation that writes succeed. Avoid merely asserting that the five configured attribute IDs exist, since that would duplicate implementation details rather than test observable behavior.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Migration/Version/V25.php
Line: 266-270

Comment:
**Missing upgrade regression coverage**

This schema repair has no behavioral test for the failure it fixes. Existing V25 coverage exercises only the functions and sites repairs, while failures here are reduced to warnings and can leave user writes broken. Add an upgrade test that begins with the affected legacy users schema, runs the migration twice, and verifies through a user create or update operation that writes succeed. Avoid merely asserting that the five configured attribute IDs exist, since that would duplicate implementation details rather than test observable behavior.

---

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

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/issue-11906 (after).

Metric Before After Change
🚀 Requests/sec 180.47 187.7 ⚪ +4%
⏱️ Latency P50 94.51 ms 92.74 ms ⚪ -1.9%
⏱️ Latency P95 221.81 ms 214.94 ms ⚪ -3.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 92.74 214.94 11,514 187.7 -6.87
Account 175.25 337.01 606 10.09 -25.64
TablesDB 88.8 167.62 6,262 103.48 -10.88
Storage 86.13 183.32 3,030 52.23 -11.8
Functions 133.11 262.98 1,616 28.56 -7.08

Top API waits (after)

API request Max wait (ms)
functions.create 538.58
account.name.update 519.56
account.prefs.update 507.04
tablesdb.rows.delete 480.95
tablesdb.rows.increment 417.64

Starts from a users collection frozen in its pre-V23 shape, runs
migrateCollections twice, then writes a user carrying the five email
metadata attributes. Without the repair the write fails with Invalid
document structure: Unknown attribute: "emailCanonical", which is the
failure an affected install actually hits; asserting the attribute ids
are present would only restate the migration.
HarshMN2345 and others added 3 commits September 22, 2026 18:19
The test built only the two collections the users arm happens to touch and
reached migrateCollections by reflection. Build the project database the
way provisioning builds it instead -- audit plus every metadata collection
from the config, with users frozen in its pre-V23 shape -- so the public
execute() entrypoint the migrate task calls can run end to end.

One run is enough for the claim in the name; the repeat run that showed the
repair was idempotent is already covered by
testV25RepairsProviderAttributesIdempotently.
@HarshMN2345
HarshMN2345 merged commit 7faac19 into main Sep 23, 2026
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.

URGENT! Missing required attribute "emailCanonical" After update to 1.9.0

2 participants