Skip to content

fix(realtime): send migration events only to project readers - #14805

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/realtime-migration-events
Oct 22, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/realtime-migration-events

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Migration realtime events (migrations.*) were addressed to the bare organization team role on the console, which every organization member holds, and were also published into the project's own subscription tree. They are now addressed to the project's read roles (organization owner/developer, or a project-<id>-owner/-developer role), the same roles that can read the project over HTTP, and published on the console only.

Changes

  • Messaging/Adapter/Realtime.php: fromPayload() gives migrations events the project's read permissions as roles; rules keeps its current mapping.
  • Workers/Migrations.php: publish migration updates to the console subscriber only. Console clients connect with project=console, and in a project's own tree team roles belong to project teams, not the organization.
  • options.downloadUrl stays in the event payload: the Console's export box merges realtime payloads into its cache and shows the Download button from that field, and everyone who now receives the event can already read the same URL through GET /v1/migrations/:migrationId. Removing it would need a Console change to refetch on completion. The API model is unchanged.

Tests

  • Unit: MessagingTest::testFromPayloadMigrationsReachOnlyProjectReaders checks the role mapping and that only a connection with a role on the project matches; it fails on main.
  • E2E (RealtimeConsoleMigrationsTest, verified by CI): the organization owner receives a project's migration event on the console channel, and a member scoped to a sibling project does not.

Related: appwrite-labs/cloud#6666

Migration events went to the bare organization team role on the console, which every member holds, and were also published into the project's own subscription tree. They carry project data, so address them to the project's read roles, the same roles that can read the project over HTTP, and publish them on the console only.

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

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

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change restricts realtime migration events to console-side sessions that hold read permissions on the target project, closing a channel where project-scoped subscribers previously received migration payloads.

Files Change
src/Appwrite/Messaging/Adapter/Realtime.php The migrations case now derives roles from getPermissionsByType(Read) on the project instead of a single team role, matching the pattern used elsewhere for project-scoped events.
src/Appwrite/Platform/Workers/Migrations.php The migration event publisher drops the project-namespace subscriber and delivers via console-only subscribers with projectId = 'console'.
tests/unit/Messaging/MessagingTest.php Unit test updated to encode the new role-matching behavior (exact permission-role strings).
tests/e2e/Services/Realtime/RealtimeConsoleMigrationsTest.php New e2e suite covering console-side delivery of migration events.

The production changes are internally consistent: role derivation matches the existing api.php pattern, all callers supply a project, and the console-only subscriber set is the stated intent of the PR. No defects above the reporting threshold were found; security review raised no concerns, and the e2e helper methods used by the new test resolve to existing Scope trait helpers.

Reviewed commit: 78169eb

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

ghost commented Oct 22, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Migration realtime events are addressed to project-reader roles and routed through the console subscription tree. The tests cover delivery to an authorized organization owner and exclusion of both a sibling-project member and a project-tree subscription.

Latest changes: The newest commit adds a project-tree websocket to the migration E2E test and factors the negative-delivery checks into a shared helper.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 4
File Change
src/Appwrite/Messaging/Adapter/Realtime.php Maps migration events to project read permissions while preserving the rules-event mapping.
src/Appwrite/Platform/Workers/Migrations.php Publishes migration update events to the console subscriber only.
tests/e2e/Services/Realtime/RealtimeConsoleMigrationsTest.php Checks owner delivery and confirms a sibling-project member and a project-tree subscription do not receive migration events.
tests/unit/Messaging/MessagingTest.php Verifies migration reader-role mapping and subscriber matching.

Reviewed the commits since 78169eb · 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 · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/realtime-migration-events (after).

Metric Before After Change
🚀 Requests/sec 215.27 220.75 ⚪ +2.5%
⏱️ Latency P50 80.31 ms 77.05 ms ⚪ -4.1%
⏱️ Latency P95 186.16 ms 189.33 ms ⚪ +1.7%
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 77.05 189.33 13,680 220.75 +3.17
Account 155.06 285.63 720 12.3 +26.72
TablesDB 75.5 151.29 7,440 122.85 +3.36
Storage 69.92 162.57 3,600 61.15 -25.52
Functions 107.92 216.65 1,920 33.27 +3.99

Top API waits (after)

API request Max wait (ms)
account.name.update 509.89
tablesdb.rows.update 466.24
tablesdb.rows.create 448.66
functions.create 443.48
functions.delete 397.7

@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 156119b into main Oct 22, 2026
36 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/realtime-migration-events branch October 22, 2026 18:19
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…#14805)

Migration events carry project data but reached every member of the organization team, and the worker also published them into the project's own subscriptions. They now go to the console channel only, for roles that can read the project.

(cherry picked from commit 156119b)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…#14805)

Migration events carry project data but reached every member of the organization team, and the worker also published them into the project's own subscriptions. They now go to the console channel only, for roles that can read the project.

(cherry picked from commit 156119b)
ChiragAgg5k added a commit that referenced this pull request Oct 24, 2026
…#14805)

Migration events carry project data but reached every member of the organization team, and the worker also published them into the project's own subscriptions. They now go to the console channel only, for roles that can read the project.

(cherry picked from commit 156119b)
Tapraj-Pathak pushed a commit to Tapraj-Pathak/appwrite that referenced this pull request Oct 24, 2026
…n-events

fix(realtime): send migration events only to project readers

(cherry picked from commit 156119b)
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