Skip to content

fix(realtime): send console project events to the project's readers - #14988

Merged
abnegate merged 1 commit into
mainfrom
fix-realtime-console-roles
Oct 27, 2026
Merged

abnegate merged 1 commit into
mainfrom
fix-realtime-console-roles

Conversation

@abnegate

Copy link
Copy Markdown
Member

What does this PR do?

Rule, project and schema (attributes, columns, indexes) events are rerouted to the console namespace and were addressed to the bare organization team role. Every organization member holds that role, including members whose roles are scoped to other projects, so those members received these events for every project in the organization.

These events now go to the project's read roles, as migration events already do. They reach the organization owners and developers, and members with a role on that project, which matches who can read the project over the HTTP API.

Function and site deployment events are handled the same way in #14976, so this PR leaves them out.

Test Plan

  • Unit: MessagingTest::testFromPayloadConsoleProjectEventsReachOnlyProjectReaders covers rule, project, attribute, column and index events. It asserts that the events go to the project's read roles, and that a member scoped to another project does not match them.
    • Without the fix, all 5 cases fail because the roles are team:org1.
    • With the fix, all 5 pass.
  • Pint, PHPStan and Rector dry run on the changed files.

Related PRs and Issues

🤖 Generated with Claude Code

Rule, project and schema events are rerouted to the console namespace and
were addressed to the bare organization team role, which every member
holds, including members whose roles are scoped to other projects. Address
them to the project's read roles instead, as migration events already are,
so they reach only members who can read the project over the HTTP API.

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

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

Copy link
Copy Markdown

Review complete. No blocking issues — approved ✅; 1 nitpick below.

🧹 Nitpicks (1) — 🟢 1 low
  • 🟢 Deployments and reports still broadcast to whole team (Realtime.php:1015) — This PR converts the rules, migrations, projects, and columns/attributes/indexes branches to $roles = $project->getPermissionsByType(PermissionType::Read) so console project-data events reach only members who can read the project, but the functions deployments case (src/Appwrite/Messaging/Adapter/Realtime.php:1015), the sites deployments case (line 1024), and the reports case (line 1040) still use the bare team role.

This PR replaces the single Role::team(teamId) role used for realtime subscriber matching with the project's full read-permission role list, aligning realtime fan-out with the HTTP-side authorization gate so events only reach users who can actually read the project. A unit test locks in that console project events reach only project readers.

Files Change
src/Appwrite/Messaging/Adapter/Realtime.php Derives subscriber roles from getPermissionsByType(PermissionType::Read) in the rules/migrations, projects, and column/attribute/index event branches instead of Role::team(teamId).
tests/unit/Messaging/MessagingTest.php Adds testFromPayloadConsoleProjectEventsReachOnlyProjectReaders covering permission-scoped fan-out.

Pre-existing sibling branches (functions/sites deployments, reports) still use unqualified team-based roles and now diverge from the changed branches.

Reviewed commit: 819e9d0

@ghost

ghost commented Oct 27, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

Console realtime routing now uses project read permissions for rule, project, and schema events, with rule events sharing the migration routing path. Added data-driven coverage for these event types and verifies that project-scoped readers receive them while members scoped to another project do not.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 2
File Change
src/Appwrite/Messaging/Adapter/Realtime.php Routes rule, project, and schema events to the roles allowed to read the project.
tests/unit/Messaging/MessagingTest.php Adds coverage for project-reader delivery and exclusion of readers scoped to other projects.

Reviewed 819e9d0 · 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

@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

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix-realtime-console-roles (after).

Metric Before After Change
🚀 Requests/sec 203.64 194.01 ⚪ -4.7%
⏱️ Latency P50 84.4 ms 89.75 ms 🔴 +6.3%
⏱️ Latency P95 204.3 ms 205.74 ms ⚪ +0.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 89.75 205.74 12,426 194.01 +1.44
Account 163.75 319.41 654 10.83 -7.36
TablesDB 87.6 159.52 6,758 108.05 +4.37
Storage 82.43 187.01 3,270 54.2 +3.31
Functions 122.06 246.11 1,744 29.46 -0.83

Top API waits (after)

API request Max wait (ms)
functions.variables.update 628.18
account.name.update 554.96
tablesdb.rows.create 439.26
account.prefs.update 431.28
storage.buckets.create 423.41

@abnegate
abnegate merged commit 5150d83 into main Oct 27, 2026
34 checks passed
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