Skip to content

[Backport of #25403] fix(data-consumption): prevent hook usage counter from going negative - #25503

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
Arthurk12:plugins-sdk/3.0/issue/275
Aug 14, 2026
Merged

[Backport of #25403] fix(data-consumption): prevent hook usage counter from going negative#25503
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
Arthurk12:plugins-sdk/3.0/issue/275

Conversation

@Arthurk12

Copy link
Copy Markdown
Member

What does this PR do?

The usage counter that tracks how many plugins are listening to a given subscription can reach negative values, which is invalid and likely indicates a bug in the unsubscribe logic.

Extract the hook usage update logic into a dedicated function that guards against negative values and logs a warning when such an update is attempted.

Closes Issue(s)

Closes N/A

More

Closely related to:

@coderabbitai

coderabbitai Bot commented Jul 23, 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: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d35fb020-b3b7-47c1-af74-6f35c8687ec6

📥 Commits

Reviewing files that changed from the base of the PR and between 35de132 and e3d0f1e.

📒 Files selected for processing (1)
  • bigbluebutton-web/grails-app/conf/bigbluebutton.properties

Walkthrough

The plugin engine now centralizes hook usage count updates. It logs a warning and clamps the result to zero when a delta would produce a negative count. Both argument-aware and general hook utilization paths use this helper. The HTML5 plugin SDK version is updated to 0.0.105 in package and server configuration.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e3d0f

This localized change prevents an invalid negative usage count and logs a warning when an invalid update is attempted; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: guileme

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the fix for negative hook usage counters and its related SDK changes.
Title check ✅ Passed The title clearly identifies the backport and the fix that prevents hook usage counters from becoming negative.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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

🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/utils.ts (1)

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

Add focused tests for the shared underflow contract.

Cover both update paths with count = 0 and delta = -1; assert the count remains 0 and the warning includes the hook name, current count, and delta. Also cover normal positive and negative updates.

🤖 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
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/utils.ts`
around lines 13 - 25, Add focused tests for applyHookUsageCountDelta covering
underflow from count 0 with delta -1, asserting a returned count of 0 and a
warning containing hookName, currentCount, and delta. Also test normal positive
and negative deltas, preserving the expected arithmetic behavior.
🤖 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 `@bigbluebutton-html5/package.json`:
- Line 82: Replace the mutable bigbluebutton-html-plugin-sdk PR URL in
package.json with an immutable committed SHA or published release version, then
regenerate the lockfile so it records the pinned dependency and resolved
tarball.

---

Nitpick comments:
In
`@bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/utils.ts`:
- Around line 13-25: Add focused tests for applyHookUsageCountDelta covering
underflow from count 0 with delta -1, asserting a returned count of 0 and a
warning containing hookName, currentCount, and delta. Also test normal positive
and negative deltas, preserving the expected arithmetic behavior.
🪄 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: 7c6bee2f-ac4e-488a-a6e0-64652a1affb5

📥 Commits

Reviewing files that changed from the base of the PR and between ee28529 and a588e4c.

⛔ Files ignored due to path filters (1)
  • bigbluebutton-html5/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • bigbluebutton-html5/imports/ui/components/plugins-engine/data-consumption/utils.ts
  • bigbluebutton-html5/package.json

Comment thread bigbluebutton-html5/package.json Outdated
@antobinary antobinary added this to the Release 3.0 milestone Jul 23, 2026
@github-actions

Copy link
Copy Markdown

This pull request has conflicts ☹
Please resolve those so we can review the pull request.
Thanks.

The usage counter that tracks how many plugins are listening to a
given subscription can reach negative values, which is invalid and
likely indicates a bug in the unsubscribe logic.

Extract the hook usage update logic into a dedicated function that
guards against negative values and logs a warning when such an
update is attempted.
@Arthurk12
Arthurk12 force-pushed the plugins-sdk/3.0/issue/275 branch from 35de132 to e3d0f1e Compare August 14, 2026 13:03
@github-actions

Copy link
Copy Markdown

Automated tests have passed!

@GuiLeme GuiLeme 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!

@ramonlsouza
ramonlsouza merged commit 73e945d into bigbluebutton:v3.0.x-develop Aug 14, 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.

4 participants