Skip to content

fix: user-specific banners failing with Banner not found error when dismissing it - #41755

Merged
tassoevan merged 4 commits into
developfrom
fix/banner-dismiss
Aug 12, 2026
Merged

fix: user-specific banners failing with Banner not found error when dismissing it#41755
tassoevan merged 4 commits into
developfrom
fix/banner-dismiss

Conversation

@nazabucciarelli

@nazabucciarelli nazabucciarelli commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

When migrating some Meteor methods to REST endpoints in #40704 we overlooked that banners.dismiss do not cover user-specific banners (banners within the user record in a banners array).

To fix this:

  • I modified the dismiss method from the BannerService to try to mark user-specific banners as read as fallback if there is none matching the rocketchat_banner collection. I did this following the banner/dismiss Meteor method current logic (the one used before).
  • The setBannerReadById User model method was modified to avoid the user from arbitrarily setting a banner in their record.
  • API tests were added covering this new behavior.

Issue(s)

SUP-1095 "Update your Rocket.Chat" banner cannot be dismissed on 8.6.0 and later

Steps to test or reproduce

  1. Login as an admin user
  2. Run the following MongoDB shell command, replacing with the proper user’s username:
    (the version number must be higher than the current one you’re using to test for the banner to show up)
db.users.updateOne(
  { username: "rocketchat.internal.admin.test" },
  { $set: { "banners.versionUpdate-8_9_0": {
      id: "versionUpdate-8_9_0",
      priority: 10,
      title: "Update_your_RocketChat",
      text: "New_version_available_(s)",
      textArguments: ["8.9.0"],
      link: "https://github.com/RocketChat/Rocket.Chat/releases/tag/8.9.0",
      modifiers: []
  } } }
)
  1. Click on the cross icon to dismiss the banner.

Expected result: Banner should be dismissed without errors and if you refresh the page it shouldn’t come back.

Further comments

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Dismissing a banner stored on a user record now marks it as read.
    • Repeated dismissal of an already-read banner succeeds safely.
    • Unknown banners now return an error without creating or modifying banner records.
    • Banner updates are skipped when no matching banner exists.
    • Banner changes are reflected promptly in the user’s session.
    • Banner dismissal behavior is now consistent across stored and standard banners.

@nazabucciarelli nazabucciarelli added this to the 8.8.0 milestone Aug 11, 2026
@nazabucciarelli
nazabucciarelli requested review from a team as code owners August 11, 2026 23:05
@dionisio-bot

dionisio-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 656c7fe

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

This PR includes changesets to release 4 packages
Name Type
@rocket.chat/models 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

@coderabbitai

coderabbitai Bot commented Aug 11, 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 Plus

Run ID: ff8f1773-6b0f-4c85-bf3a-5e36b9b324d4

📥 Commits

Reviewing files that changed from the base of the PR and between b7993c7 and 656c7fe.

📒 Files selected for processing (1)
  • apps/meteor/tests/end-to-end/api/banners.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/tests/end-to-end/api/banners.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
⚠️ 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** — 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**

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**

Walkthrough

The banner dismissal flow now marks matching banners in user records as read, emits a user-change notification, and returns Banner not found only when no matching banner exists. End-to-end tests cover first dismissal, repeated dismissal, and unknown banner IDs.

Changes

Banner dismissal

Layer / File(s) Summary
User banner read-state update
packages/models/src/models/Users.ts
setBannerReadById now updates a user only when the specified banner exists in the user record.
Dismissal service and validation
apps/meteor/server/services/banner/service.ts, apps/meteor/tests/end-to-end/api/banners.ts, .changeset/some-banks-spend.md
The dismissal service updates user-record banners, publishes an updated user-change notification, and returns Banner not found only when no record matches. End-to-end tests cover dismissal, repeated dismissal, and unknown banner IDs. The changeset documents the behavior.

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

Suggested labels: type: bug

Sequence Diagram(s)

sequenceDiagram
  participant BannerAPI
  participant BannerService
  participant Users
  participant UserChangeNotifier
  BannerAPI->>BannerService: dismiss banner
  BannerService->>Users: setBannerReadById
  Users-->>BannerService: update result
  BannerService->>UserChangeNotifier: publish updated user change
  BannerService-->>BannerAPI: success or Banner not found
Loading
🚥 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 for user-specific banners incorrectly returning a Banner not found error during dismissal.
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 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • SUP-1095: 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.

@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 `@apps/meteor/tests/end-to-end/api/banners.ts`:
- Around line 88-90: Update the after teardown hook to unset the seeded
banners.alert-user-banner-test field from the admin user record before invoking
connection.close(). Reuse the existing connection and admin-user update
mechanism, then preserve the current connection shutdown behavior.
🪄 Autofix

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 Plus

Run ID: 42f4e24d-1831-4f79-abe0-1ca87e4e5b5a

📥 Commits

Reviewing files that changed from the base of the PR and between 49873a6 and a793072.

📒 Files selected for processing (4)
  • .changeset/some-banks-spend.md
  • apps/meteor/server/services/banner/service.ts
  • apps/meteor/tests/end-to-end/api/banners.ts
  • packages/models/src/models/Users.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: 📦 Build Packages
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/models/src/models/Users.ts
  • apps/meteor/tests/end-to-end/api/banners.ts
  • apps/meteor/server/services/banner/service.ts
packages/**

📄 CodeRabbit inference engine (CLAUDE.md)

Shared libraries belong in packages/, while other services belong in apps/ and ee/.

Files:

  • packages/models/src/models/Users.ts
apps/meteor/**

📄 CodeRabbit inference engine (CLAUDE.md)

The main Rocket.Chat Meteor application resides in apps/meteor/; place its application code there rather than in other monorepo areas.

Files:

  • apps/meteor/tests/end-to-end/api/banners.ts
  • apps/meteor/server/services/banner/service.ts
🧠 Learnings (6)
📚 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/models/src/models/Users.ts
  • apps/meteor/tests/end-to-end/api/banners.ts
  • apps/meteor/server/services/banner/service.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/models/src/models/Users.ts
  • apps/meteor/tests/end-to-end/api/banners.ts
  • apps/meteor/server/services/banner/service.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/models/src/models/Users.ts
  • apps/meteor/tests/end-to-end/api/banners.ts
  • apps/meteor/server/services/banner/service.ts
📚 Learning: 2026-07-15T01:31:50.632Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41382
File: packages/model-typings/src/models/IPushTokenModel.ts:10-10
Timestamp: 2026-07-15T01:31:50.632Z
Learning: In Rocket.Chat’s push-token model, APNs/GCM standard tokens and PushKit VoIP tokens use distinct, globally-unique token string values. As a result, when deduplicating/looking up tokens, key identity solely on `{ tokenValue, appName }` (e.g., for `findOneByTokenAndAppName`, `removeDuplicateTokens`) and do **not** include `tokenType` in the uniqueness criteria to avoid collisions between standard and VoIP tokens.

Applied to files:

  • packages/models/src/models/Users.ts
📚 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/some-banks-spend.md
📚 Learning: 2026-08-05T22:02:59.828Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 41707
File: apps/meteor/server/hooks/messages/processThreads.ts:66-68
Timestamp: 2026-08-05T22:02:59.828Z
Learning: In Rocket.Chat Meteor server code, `callbacks.runAsync` returns its input item rather than the asynchronous callback promise. Callers of `afterReadMessages` must invoke `callbacks.runAsync` without awaiting it, keeping read-receipt I/O off the message-send path; this includes `apps/meteor/server/hooks/messages/processThreads.ts`.

Applied to files:

  • apps/meteor/server/services/banner/service.ts
🪛 LanguageTool
.changeset/some-banks-spend.md

[grammar] ~6-~6: Ensure spelling is correct
Context: ...oes not exist in the banners collection nor in the user's record.

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (4)
packages/models/src/models/Users.ts (1)

2915-2927: LGTM!

apps/meteor/server/services/banner/service.ts (1)

8-9: LGTM!

Also applies to: 92-106

apps/meteor/tests/end-to-end/api/banners.ts (1)

1-8: LGTM!

Also applies to: 57-86, 92-139

.changeset/some-banks-spend.md (1)

1-6: LGTM!

Comment thread apps/meteor/tests/end-to-end/api/banners.ts

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

All reported issues were addressed across 4 files

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

Re-trigger cubic

Comment thread apps/meteor/tests/end-to-end/api/banners.ts
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.71%. Comparing base (93aa04b) to head (656c7fe).
⚠️ Report is 16 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41755      +/-   ##
===========================================
+ Coverage    68.68%   68.71%   +0.02%     
===========================================
  Files         4166     4168       +2     
  Lines       159382   159492     +110     
  Branches     28253    28302      +49     
===========================================
+ Hits        109479   109595     +116     
+ Misses       44747    44737      -10     
- Partials      5156     5160       +4     
Flag Coverage Δ
e2e 58.90% <ø> (ø)
e2e-api 45.77% <100.00%> (+0.05%) ⬆️
unit 70.61% <16.66%> (+0.02%) ⬆️

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.

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

All reported issues were addressed across 1 file (changes from recent commits).

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

Re-trigger cubic

Comment thread apps/meteor/tests/end-to-end/api/banners.ts Outdated
@abhinavkrin abhinavkrin added the stat: QA assured Means it has been tested and approved by a company insider label Aug 12, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Aug 12, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026
@nazabucciarelli nazabucciarelli added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels Aug 12, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026
@nazabucciarelli nazabucciarelli added stat: ready to merge PR tested and approved waiting for merge and removed stat: ready to merge PR tested and approved waiting for merge labels Aug 12, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026
@nazabucciarelli nazabucciarelli removed the stat: ready to merge PR tested and approved waiting for merge label Aug 12, 2026
@nazabucciarelli nazabucciarelli added the stat: ready to merge PR tested and approved waiting for merge label Aug 12, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Aug 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 12, 2026
@tassoevan
tassoevan added this pull request to the merge queue Aug 12, 2026
Merged via the queue into develop with commit 5deefe2 Aug 12, 2026
84 of 86 checks passed
@tassoevan
tassoevan deleted the fix/banner-dismiss branch August 12, 2026 22:54
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.

3 participants