Skip to content

fix: race condition in E2EE rooms creation causing 'incorrect encryption key' error - #41169

Merged
dionisio-bot[bot] merged 9 commits into
developfrom
fix/e2ee-rooms-race-cond
Jul 16, 2026
Merged

fix: race condition in E2EE rooms creation causing 'incorrect encryption key' error#41169
dionisio-bot[bot] merged 9 commits into
developfrom
fix/e2ee-rooms-race-cond

Conversation

@nazabucciarelli

@nazabucciarelli nazabucciarelli commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

There was a race condition occurring when a E2EE room is created with several online users. It happens because when the room is created, every online added user triggers a request to the e2e.setRoomKeyID endpoint concurrently, which isn't atomic (it first reads the room, then checks if it has e2eKeyId, and if it doesn't have it, then another roundtrip to the database is performed to add the key). This two-phase behavior caused stale states for users who lost the race.

To address this:

  • Added $exists condition to the e2eKeyId property in the query of the Rooms.setE2eKeyId model method. This avoids overwriting the value if another user already won the race. Also the Rooms.findOneById query was removed, since we are already checking for room availability with canAccessRoomIdAsync.
  • Added frontend handling: in case the user loses the race, it discards the local stored IDs and its state changes to WAITING_KEYS.
  • Tests: It's difficult to create a test that guarantees that no race condition occur here, therefore I've created a frontend unit test file (apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts) checking the local values are discarded if another user won the race.

Issue(s)

SUP-1067 E2EE: rooms created with encryption enabled at creation leave members' messages undecryptable ("incorrect encryption key")

Steps to test or reproduce

  1. Create at least two more users besides yours in order to reproduce this race condition. All members need to be online (different tabs).
  2. Create a private group with "Encrypted" enabled in the creation dialog, adding the online new members at creation.
  3. Observe messages from one or more members render the "incorrect encryption key" ephemeral message for everyone.

To reproduce this even more consistently, I'd recommend to have five or more users online concurrently.

Further comments

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a race condition when multiple participants open an encrypted room simultaneously.
    • Ensured only one group key is established for each room.
    • Clients that lose the race now discard their local key and use the server-established key, preventing undecryptable messages.
  • Tests

    • Added coverage for both winning and losing concurrent key-creation scenarios.

@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 04e8f12

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@rocket.chat/models Patch
@rocket.chat/model-typings Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dionisio-bot

dionisio-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 17a953aa-fb1d-4b61-bdd7-5404aafa6471

📥 Commits

Reviewing files that changed from the base of the PR and between d6c12c3 and 04e8f12.

📒 Files selected for processing (1)
  • .changeset/four-tigers-clap.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/four-tigers-clap.md
📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
⚠️ CI failures not shown inline (5)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

Walkthrough

Encrypted-room key establishment now uses server-side first-write-wins semantics. Clients that lose concurrent key creation discard their local key and wait for the established key. Model typings, race outcome tests, and patch release metadata are updated.

Changes

Atomic room key assignment

Layer / File(s) Summary
Server-side atomic key assignment
packages/model-typings/src/models/IRoomsModel.ts, packages/models/src/models/Rooms.ts
setE2eKeyId now updates only rooms without an existing e2eKeyId and returns the updated room or null.
Client race handling in E2ERoom
apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
createGroupKey() detects existing-key responses, discards local key material when it loses, and makes handshake() enter WAITING_KEYS.
Race outcome tests and release metadata
apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts, .changeset/four-tigers-clap.md
Tests cover winning and losing key-creation paths, and the changeset records patch releases and the concurrency fix.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2ERoom
  participant REST API
  participant RoomsRaw
  E2ERoom->>REST API: POST setRoomKeyID(keyID)
  REST API->>RoomsRaw: setE2eKeyId(roomId, keyID)
  RoomsRaw-->>REST API: updated room or null
  REST API-->>E2ERoom: success or already-exists error
  E2ERoom->>E2ERoom: distribute key or discard local key and wait
Loading

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main fix: an E2EE room creation race condition causing incorrect encryption key errors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SUP-1067: Request failed with status code 401

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.44444% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.45%. Comparing base (abab8a0) to head (04e8f12).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41169      +/-   ##
===========================================
- Coverage    68.47%   68.45%   -0.02%     
===========================================
  Files         4092     4092              
  Lines       158285   158362      +77     
  Branches     28622    28667      +45     
===========================================
+ Hits        108379   108406      +27     
- Misses       44874    44924      +50     
  Partials      5032     5032              
Flag Coverage Δ
e2e 59.20% <28.57%> (-0.13%) ⬇️
e2e-api 45.50% <0.00%> (+<0.01%) ⬆️
unit 70.31% <70.58%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nazabucciarelli
nazabucciarelli marked this pull request as ready for review July 6, 2026 15:43
@nazabucciarelli
nazabucciarelli requested review from a team as code owners July 6, 2026 15:43
@nazabucciarelli nazabucciarelli added this to the 8.7.0 milestone Jul 6, 2026

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (2)
apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts (1)

82-82: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid unsafe type cast for keyID on discard; widen the field type instead.

this.keyID = undefined as unknown as string; forces an invalid value through the type system. Since discardGroupKey() legitimately needs to clear the key, the underlying [KEY_ID] field should be typed as string | undefined.

As per coding guidelines, "Write concise, technical TypeScript/JavaScript with accurate typing" (**/*.{ts,tsx,js}).

♻️ Proposed fix
-	[KEY_ID]: string;
+	[KEY_ID]: string | undefined;
 	private discardGroupKey() {
 		this.groupSessionKey = null;
 		this.sessionKeyExportedString = undefined;
-		this.keyID = undefined as unknown as string;
+		this.keyID = undefined;
 	}

Also applies to: 437-456

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts` at line 82, The
`[KEY_ID]` field in `RocketchatE2ERoom` is typed too narrowly, which forces an
unsafe cast when `discardGroupKey()` clears it. Widen the field declaration to
allow `undefined`, and update the related `keyID` accessors/assignment in
`discardGroupKey()` so the value can be cleared without any `as unknown as
string` cast. Keep the typing consistent anywhere `KEY_ID` is read or written in
this class.

Source: Coding guidelines

apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts (1)

38-51: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add coverage for the rethrow path.

Only the "already exists" error path is tested. Consider adding a case where sdk.rest.post rejects with a Response carrying a different errorType (or a non-Response error) to assert createGroupKey() rethrows rather than silently discarding the key.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts` around lines 38 -
51, The current `createGroupKey()` test only covers the
`error-room-e2e-key-already-exists` discard path, so add a separate spec in
`rocketchat.e2e.room.spec.ts` that makes `sdk.rest.post` reject with a different
`Response.errorType` or a non-`Response` error and asserts the
`createGroupKey()` call rethrows. Use `makeRoom()` and
`e2eRoom.createGroupKey()` to locate the behavior, and verify it does not return
`false` or clear `groupSessionKey`/`keyID` when the error is not the race-lost
case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts`:
- Around line 38-51: The current `createGroupKey()` test only covers the
`error-room-e2e-key-already-exists` discard path, so add a separate spec in
`rocketchat.e2e.room.spec.ts` that makes `sdk.rest.post` reject with a different
`Response.errorType` or a non-`Response` error and asserts the
`createGroupKey()` call rethrows. Use `makeRoom()` and
`e2eRoom.createGroupKey()` to locate the behavior, and verify it does not return
`false` or clear `groupSessionKey`/`keyID` when the error is not the race-lost
case.

In `@apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts`:
- Line 82: The `[KEY_ID]` field in `RocketchatE2ERoom` is typed too narrowly,
which forces an unsafe cast when `discardGroupKey()` clears it. Widen the field
declaration to allow `undefined`, and update the related `keyID`
accessors/assignment in `discardGroupKey()` so the value can be cleared without
any `as unknown as string` cast. Keep the typing consistent anywhere `KEY_ID` is
read or written in this class.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 328e0ae3-8649-4ff4-9323-3c7fffd79b90

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc4964 and 0a9ca06.

📒 Files selected for processing (5)
  • .changeset/four-tigers-clap.md
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
  • packages/models/src/models/Rooms.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: 🚢 Build Docker (arm64, rocketchat, coverage)
  • GitHub Check: 🚢 Build Docker (arm64, account-service, presence-service, omnichannel-transcript-service, cove...
  • GitHub Check: 🚢 Build Docker (arm64, authorization-service, queue-worker-service, ddp-streamer-service, cove...
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use .spec.ts extension for test files (e.g., login.spec.ts)

Files:

  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
🧠 Learnings (8)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/four-tigers-clap.md
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
🔇 Additional comments (8)
packages/models/src/models/Rooms.ts (2)

1218-1233: LGTM!


1218-1233: 🎯 Functional Correctness

Check whether any caller depends on setE2eKeyId overwriting an existing value; this now no-ops when e2eKeyId is already set.

apps/meteor/app/e2e/server/methods/setRoomKeyID.ts (1)

22-34: LGTM!

apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts (3)

37-45: LGTM!


457-467: LGTM!


343-348: 🎯 Functional Correctness

Ensure the race-lost branch still requests the room key The !created path only switches to WAITING_KEYS; if the proactive key push is missed, this client has no fallback request and can remain stuck.

apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts (1)

31-64: LGTM!

.changeset/four-tigers-clap.md (1)

1-7: LGTM!

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

2 issues found across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.room.ts
Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
Comment thread apps/meteor/app/e2e/server/methods/setRoomKeyID.ts Outdated
Comment thread .changeset/four-tigers-clap.md Outdated

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/model-typings/src/models/IRoomsModel.ts`:
- Line 230: The `IRoomsModel.setE2eKeyId` signature is still typed with the
wrong options type, so update the interface to match `RoomsRaw.setE2eKeyId` by
replacing `FindOptions<IRoom>` with `FindOneAndUpdateOptions`. Also adjust the
imports in `IRoomsModel` so the matching option type is referenced consistently
with the implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b230980f-4e87-4e29-ad1a-95dfbf18abf8

📥 Commits

Reviewing files that changed from the base of the PR and between 0a9ca06 and 280c21a.

📒 Files selected for processing (5)
  • .changeset/four-tigers-clap.md
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
  • packages/model-typings/src/models/IRoomsModel.ts
  • packages/models/src/models/Rooms.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/four-tigers-clap.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.room.spec.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
⚠️ CI failures not shown inline (3)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ❌ **QA assured** — This PR is missing the 'stat: QA assured' label
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/model-typings/src/models/IRoomsModel.ts
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/model-typings/src/models/IRoomsModel.ts
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/model-typings/src/models/IRoomsModel.ts
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • packages/model-typings/src/models/IRoomsModel.ts
  • apps/meteor/app/e2e/server/methods/setRoomKeyID.ts
  • packages/models/src/models/Rooms.ts
🔇 Additional comments (2)
apps/meteor/app/e2e/server/methods/setRoomKeyID.ts (1)

22-30: This implements the previously requested change to use findOneAndUpdate and pass the full room document to the notifier.

packages/models/src/models/Rooms.ts (1)

1219-1233: LGTM!

Comment thread packages/model-typings/src/models/IRoomsModel.ts Outdated
@nazabucciarelli
nazabucciarelli requested a review from KevLehman July 6, 2026 19:57

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

1 issue found across 1 file (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/model-typings/src/models/IRoomsModel.ts Outdated
cardoso
cardoso previously approved these changes Jul 7, 2026
KevLehman
KevLehman previously approved these changes Jul 7, 2026
tassoevan
tassoevan previously approved these changes Jul 9, 2026

@tassoevan tassoevan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved, but because I don't remember if there is any legit workflow where overriding the E2E key is a valid operation.

@KevLehman
KevLehman dismissed stale reviews from tassoevan, cardoso, and themself via 88d05ef July 13, 2026 13:14
@KevLehman
KevLehman force-pushed the fix/e2ee-rooms-race-cond branch from d6c12c3 to 88d05ef Compare July 13, 2026 13:14
@KevLehman
KevLehman requested a review from a team as a code owner July 13, 2026 13:14
KevLehman
KevLehman previously approved these changes Jul 13, 2026
@KevLehman
KevLehman requested review from cardoso and tassoevan July 13, 2026 14:43
tassoevan
tassoevan previously approved these changes Jul 15, 2026
cardoso
cardoso previously approved these changes Jul 15, 2026
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Jul 15, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 15, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 15, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jul 15, 2026
@KevLehman
KevLehman dismissed stale reviews from cardoso, tassoevan, and themself via 04e8f12 July 16, 2026 18:36
@KevLehman
KevLehman force-pushed the fix/e2ee-rooms-race-cond branch from 88d05ef to 04e8f12 Compare July 16, 2026 18:36
@KevLehman
KevLehman requested review from cardoso and tassoevan July 16, 2026 19:49
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 16, 2026
@KevLehman
KevLehman removed this pull request from the merge queue due to a manual request Jul 16, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 16, 2026
Merged via the queue into develop with commit ffe1b64 Jul 16, 2026
83 of 85 checks passed
@dionisio-bot
dionisio-bot Bot deleted the fix/e2ee-rooms-race-cond branch July 16, 2026 22:32
This was referenced Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants