Skip to content

fix(breakouts): user id handling - #24986

Merged
antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
Arthurk12:bbb/30/24398
May 8, 2026
Merged

antobinary merged 3 commits into
bigbluebutton:v3.0.x-developfrom
Arthurk12:bbb/30/24398

Conversation

@Arthurk12

@Arthurk12 Arthurk12 commented Apr 28, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

  • fix(breakouts): correct external user ID extraction
    Breakout rooms build the user ID by appending -<roomNumber> to the external user ID. The previous extraction logic retrieved the original external ID by taking the first chunk of the hyphen-separated string.
    This caused issues in edge cases where users joined with prefixed external IDs. For example, myprefix-w_r12ch33-1 was incorrectly extracted as myprefix.
    The extraction logic now removes only the last hyphen-separated segment, ensuring the original external user ID is preserved.
  • refactor(akka): reduce duplicate code by extracting to helper function
    Extracts the duplicate code from RegisteredUsers and Users2x to a helper function declared in HandlerHelpers as suggested by @prlanzarin in the PR's review.
  • fix(breakouts): find user in main room matching internal user id
  • Reverts the breakout room join url creation to use the user's internal id in the main room as the user's external id in the breakout room.
  • Adjusts the user matching logic to compare the correct fields and make the code more readable.

Closes Issue(s)

Closes #24398

@coderabbitai

coderabbitai Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Replaces per-type breakout-room lookup helpers with shared utilities in a new HandlerHelpers trait. HandlerHelpers adds methods to extract a main-room internal user id from a breakout external id, match by that id across generic user vectors, and provide overloads for Users2x and RegisteredUsers. The trait is mixed into BreakoutRoomUsersUpdateMsgHdlr, which now calls findUserInMainRoom(...) and renames resolved variables to parentMeetingUser. The now-unused findWithBreakoutRoomId helpers were removed from Users2x and RegisteredUsers.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(breakouts): user id handling' accurately describes the main changes: refactoring user ID handling logic in breakout rooms, including extraction of main-room user IDs and removing obsolete lookup methods.
Linked Issues check ✅ Passed The PR addresses the root cause of issue #24398 by fixing user ID handling inconsistencies that prevent proper user identification across main and breakout rooms, which is necessary for the inactivity check to correctly identify users in breakout rooms.
Out of Scope Changes check ✅ Passed All changes are scoped to user ID handling in breakout rooms: extracting main-room user IDs from breakout user IDs, removing obsolete lookup methods, and updating handlers to use the new helper methods.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing fixes for external user ID extraction in breakout rooms and refactoring to reduce code duplication.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@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 the current code and only fix it if needed.

Inline comments:
In
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala`:
- Around line 25-37: The lookup strips the breakout suffix but still compares to
internal ids (using _.intId / _.id), so users whose breakout URL was built from
their external id are missed; update matchByBreakoutRoomExtUserId to compare the
extracted main-room id against the user’s external id by changing the extractor
passed from _.intId / _.id to the users' external-id accessor (e.g., _.extId or
_.externalId) and/or rename the extractor parameter to make it clear it should
return the id used in breakout URLs; adjust the two callers
findUserInMainRoom(Users2x, ...) and findUserInMainRoom(RegisteredUsers, ...) to
pass the correct external-id accessor (instead of _.intId / _.id) so the
comparison matches breakoutRoomExtUserId after stripping.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 79930866-053a-46e2-918b-720abda656c0

📥 Commits

Reviewing files that changed from the base of the PR and between 3e981fb and c39a014.

📒 Files selected for processing (4)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
💤 Files with no reviewable changes (2)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala

Comment on lines +25 to +37
def matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = {
// The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence
val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId)
users.find(user => extractInternalUserId(user) == mainRoomInternalUserId)
}

def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = {
matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId)
}

def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = {
matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id)
}

@coderabbitai coderabbitai Bot Apr 28, 2026 •

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.

⚠️ Potential issue | 🟠 Major

Match the lookup key to the breakout ID source.

findUserInMainRoom strips the breakout suffix, but it still compares against intId / id. If breakout URLs are now built from external IDs, this lookup will return None for users whose external and internal IDs differ, and the parent-room inactivity / breakout bookkeeping in BreakoutRoomUsersUpdateMsgHdlr will silently skip them.

Proposed fix
 def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = {
-  matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId)
+  matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.extId)
 }

 def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = {
-  matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id)
+  matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.externId)
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = {
// The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence
val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId)
users.find(user => extractInternalUserId(user) == mainRoomInternalUserId)
}
def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = {
matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId)
}
def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = {
matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id)
}
def matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = {
// The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence
val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId)
users.find(user => extractInternalUserId(user) == mainRoomInternalUserId)
}
def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = {
matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.extId)
}
def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = {
matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.externId)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala`
around lines 25 - 37, The lookup strips the breakout suffix but still compares
to internal ids (using _.intId / _.id), so users whose breakout URL was built
from their external id are missed; update matchByBreakoutRoomExtUserId to
compare the extracted main-room id against the user’s external id by changing
the extractor passed from _.intId / _.id to the users' external-id accessor
(e.g., _.extId or _.externalId) and/or rename the extractor parameter to make it
clear it should return the id used in breakout URLs; adjust the two callers
findUserInMainRoom(Users2x, ...) and findUserInMainRoom(RegisteredUsers, ...) to
pass the correct external-id accessor (instead of _.intId / _.id) so the
comparison matches breakoutRoomExtUserId after stripping.

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.

It was reverted, now the breakout user's extId is constructed from the main room user's intId, not from extId.

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.

@gustavotrott, thanks for the clarification! That makes sense — since the breakout room user's extId is {mainRoom.intId}-{roomNumber}, stripping the last segment correctly recovers the main room's intId, and comparing against _.intId / _.id is the right approach. My suggestion to switch to _.extId / _.externId was based on a wrong assumption. The current code is correct.

🐰 🔍 twitches nose thoughtfully


✏️ Learnings added
Learnt from: gustavotrott
Repo: bigbluebutton/bigbluebutton PR: 24986
File: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala:25-37
Timestamp: 2026-05-06T12:43:30.037Z
Learning: In BigBlueButton (BBB), a breakout room user's external ID (`extId`) is constructed as `{mainRoomUser.intId}-{roomNumber}`. The `extractMainRoomInternalUserId` helper in `HandlerHelpers.scala` strips the last hyphen-separated segment to recover the main room's internal user ID (`intId`). Therefore, `findUserInMainRoom` correctly compares the extracted value against `_.intId` (for `Users2x`) and `_.id` (for `RegisteredUsers`), NOT against `_.extId` / `_.externId`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@gustavotrott gustavotrott 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.

In the PR description you mention that "The join URL now correctly uses the external user ID", but this was reverted in commit c39a014.

It's confusing. Please update the description to reflect the current state of the code and reference commits from this PR.

Arthurk12 added 3 commits May 4, 2026 14:19
Breakout rooms build the user ID by appending `-<roomNumber>` to the
external user ID. The previous extraction logic retrieved the original
external ID by taking the first chunk of the hyphen-separated string.

This caused issues in edge cases where users joined with prefixed
external IDs. For example, `myprefix-w_r12ch33-1` was incorrectly
extracted as `myprefix`.

The extraction logic now removes only the last hyphen-separated segment,
ensuring the original external user ID is preserved.
Extracts the duplicate code from RegisteredUsers and Users2x to a helper
function declared in HandlerHelpers as suggested by @prlanzarin in the
PR's review.
- Reverts the breakout room join url creation to use the user's internal id in
  the main room as the user's external id in the breakout room.
- Adjusts the user matching logic to compare the correct fields and make
  the code more readable.
@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@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 (1)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala (1)

29-43: ⚡ Quick win

Duplicate findUserInMainRoom(liveMeeting.registeredUsers, ...) per user — merge the two for-comprehensions.

Lines 29-36 and 38-43 each independently scan liveMeeting.registeredUsers for the same breakoutRoomUser.extId. Combining them into a single for-comprehension eliminates the redundant lookup.

♻️ Proposed refactor
-      //Update lastBreakout in registeredUsers to avoid lose this info when the user leaves
-      for {
-        breakoutRoomUser <- updatedRoom.users
-        parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId)
-      } yield {
-        if (room != null && (parentMeetingUser.lastBreakoutRoom == null || parentMeetingUser.lastBreakoutRoom.id != room.id)) {
-          RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers, parentMeetingUser, room)
-        }
-      }
-
-      for {
-        breakoutRoomUser <- updatedRoom.users
-        parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId)
-      } yield {
-        BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser, updatedRoom)
-      }
+      //Update lastBreakout in registeredUsers to avoid lose this info when the user leaves
+      for {
+        breakoutRoomUser <- updatedRoom.users
+        parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId)
+      } yield {
+        if (parentMeetingUser.lastBreakoutRoom == null || parentMeetingUser.lastBreakoutRoom.id != room.id) {
+          RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers, parentMeetingUser, room)
+        }
+        BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser, updatedRoom)
+      }

Note: The room != null guard is also dropped above — room is extracted from a model.find(...) Option and is guaranteed non-null within the outer for-comprehension's yield block.

🤖 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
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala`
around lines 29 - 43, Merge the two identical for-comprehensions into one inside
BreakoutRoomUsersUpdateMsgHdlr: iterate updatedRoom.users and call
findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) once per
breakoutRoomUser, then inside the single body invoke
RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers,
parentMeetingUser, room) (respecting the existing guard logic or dropping the
redundant room != null check if room is already an Option-derived value) and
BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser,
updatedRoom); this removes the duplicate lookup and keeps both updates per user
in one pass.
🤖 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
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala`:
- Around line 29-43: Merge the two identical for-comprehensions into one inside
BreakoutRoomUsersUpdateMsgHdlr: iterate updatedRoom.users and call
findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) once per
breakoutRoomUser, then inside the single body invoke
RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers,
parentMeetingUser, room) (respecting the existing guard logic or dropping the
redundant room != null check if room is already an Option-derived value) and
BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser,
updatedRoom); this removes the duplicate lookup and keeps both updates per user
in one pass.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 45c4ddc9-ab98-4c6c-9c10-97ac670b89a7

📥 Commits

Reviewing files that changed from the base of the PR and between c39a014 and 248d11b.

📒 Files selected for processing (4)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
💤 Files with no reviewable changes (2)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
🚧 Files skipped from review as they are similar to previous changes (1)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala

@gustavotrott gustavotrott 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.

LGTM, well done!

Let's wait for Automated Tests before merging.

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

✅ Automated tests have passed!

@antobinary
antobinary merged commit 44ed4c4 into bigbluebutton:v3.0.x-develop May 8, 2026
76 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inactivity check triggers in main room while breakout rooms are running

3 participants