Skip to content

fix: interpolate username in welcome messages - #41724

Open
AlgoArtist06 wants to merge 2 commits into
RocketChat:developfrom
AlgoArtist06:pr/fix-welcome-interpolation-2026-08-09
Open

fix: interpolate username in welcome messages#41724
AlgoArtist06 wants to merge 2 commits into
RocketChat:developfrom
AlgoArtist06:pr/fix-welcome-interpolation-2026-08-09

Conversation

@AlgoArtist06

@AlgoArtist06 AlgoArtist06 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Welcome system messages use the legacy %s translation placeholder. The formatter passed a named interpolation object, causing the username to render as a raw placeholder or object value depending on the translation path.

This change passes the username through the standard i18next sprintf postprocessor and adds regression coverage for the formatter contract.

Issue(s)

Fixes #16055

Steps to test or reproduce

  1. Log in with a workspace welcome message enabled.
  2. Verify the welcome system message displays the username instead of %s.

Automated verification:

  • corepack yarn workspace @rocket.chat/message-types test --runInBand: 6 passed
  • corepack yarn eslint packages/message-types/src/MessageTypes.spec.ts packages/message-types/src/registrations/common.ts: passed
  • corepack yarn workspace @rocket.chat/message-types build: passed
  • corepack yarn changeset status: passed

The full Rocket.Chat test suite was not run because it is impractical for this focused monorepo change.

Further comments

A patch changeset for @rocket.chat/meteor is included. Existing locale files remain unchanged.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Fixed welcome messages displaying a raw placeholder instead of the recipient’s username.
    • Welcome messages now correctly insert the username into the translated text.

@dionisio-bot

dionisio-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: baab6a2

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

This PR includes changesets to release 3 packages
Name Type
@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 9, 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: 3ae72748-ddb8-4f94-8015-6936f8f1747b

📥 Commits

Reviewing files that changed from the base of the PR and between 71a97f0 and baab6a2.

📒 Files selected for processing (1)
  • packages/message-types/src/MessageTypes.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/message-types/src/MessageTypes.spec.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer

Walkthrough

The welcome system message now passes the username through sprintf formatting. Tests verify the translation arguments and rendered output. A patch changeset documents the fix.

Changes

Welcome message formatting

Layer / File(s) Summary
Welcome formatter and validation
packages/message-types/src/registrations/common.ts, packages/message-types/src/MessageTypes.spec.ts, .changeset/fix-welcome-message-interpolation.md
The wm registration supplies the username as a sprintf argument. Tests verify the translated output and formatter options. A patch changeset records the fix.

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

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 change: interpolating the username in welcome messages.
Linked Issues check ✅ Passed The implementation and regression test address issue #16055 by replacing the literal %s with the username.
Out of Scope Changes check ✅ Passed The implementation, regression test, and changeset are directly related to the welcome-message interpolation fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • INTERPOLATION-2026: 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.

🧹 Nitpick comments (1)
packages/message-types/src/MessageTypes.spec.ts (1)

62-64: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the mocked translator use the sprintf argument.

Line 62 returns a fixed string and ignores the options passed to translate. Therefore, Line 64 cannot detect a literal %s or an incorrect username. The call assertion checks the option contract, but it does not verify rendered interpolation.

Make the mock derive the result from options.sprintf[0], or run the case through the real i18next sprintf postprocessor.

Example test adjustment
-	const translate = jest.fn(() => 'Welcome <em>user</em>.') as unknown as TFunction;
+	const translate = jest.fn(
+		(_key: string, options: { postProcess?: string; sprintf?: [string] }) =>
+			options.postProcess === 'sprintf' ? `Welcome <em>${options.sprintf?.[0] ?? '%s'}</em>.` : 'Welcome %s.',
+	) as unknown as TFunction;
🤖 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 `@packages/message-types/src/MessageTypes.spec.ts` around lines 62 - 64, Update
the mocked translate function in the welcomeMessage test to derive its rendered
output from the provided options.sprintf[0] value instead of returning a fixed
string. Keep the existing call assertion and verify that welcomeMessage.text
renders the supplied username, catching literal interpolation tokens or
incorrect values.
🤖 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 `@packages/message-types/src/MessageTypes.spec.ts`:
- Around line 62-64: Update the mocked translate function in the welcomeMessage
test to derive its rendered output from the provided options.sprintf[0] value
instead of returning a fixed string. Keep the existing call assertion and verify
that welcomeMessage.text renders the supplied username, catching literal
interpolation tokens or incorrect values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 217c007c-5d97-474f-bc8a-eae15ac977b2

📥 Commits

Reviewing files that changed from the base of the PR and between 73b6281 and 71a97f0.

📒 Files selected for processing (3)
  • .changeset/fix-welcome-message-interpolation.md
  • packages/message-types/src/MessageTypes.spec.ts
  • packages/message-types/src/registrations/common.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 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/message-types/src/registrations/common.ts
  • packages/message-types/src/MessageTypes.spec.ts
packages/**

📄 CodeRabbit inference engine (CLAUDE.md)

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

Files:

  • packages/message-types/src/registrations/common.ts
  • packages/message-types/src/MessageTypes.spec.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:

  • packages/message-types/src/MessageTypes.spec.ts
🧠 Learnings (7)
📚 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/fix-welcome-message-interpolation.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:

  • packages/message-types/src/registrations/common.ts
  • packages/message-types/src/MessageTypes.spec.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/message-types/src/registrations/common.ts
  • packages/message-types/src/MessageTypes.spec.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/message-types/src/registrations/common.ts
  • packages/message-types/src/MessageTypes.spec.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.

Applied to files:

  • packages/message-types/src/MessageTypes.spec.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:

  • packages/message-types/src/MessageTypes.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:

  • packages/message-types/src/MessageTypes.spec.ts
🔇 Additional comments (3)
packages/message-types/src/registrations/common.ts (1)

109-109: LGTM!

packages/message-types/src/MessageTypes.spec.ts (1)

2-5: LGTM!

.changeset/fix-welcome-message-interpolation.md (1)

1-5: 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.

Review completed against the latest diff

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

Re-trigger cubic

Comment thread packages/message-types/src/MessageTypes.spec.ts
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.

Welcome message not parsed when logging into Rocket.Chat

1 participant