Skip to content

feat: Add phone support to user#40697

Open
aleksandernsilva wants to merge 14 commits into
developfrom
feat/user-phones
Open

feat: Add phone support to user#40697
aleksandernsilva wants to merge 14 commits into
developfrom
feat/user-phones

Conversation

@aleksandernsilva
Copy link
Copy Markdown
Contributor

@aleksandernsilva aleksandernsilva commented May 26, 2026

Proposed changes (including videos or screenshots)

This PR adds support for multiple phone numbers per user across the application, replacing the previous single phone field with a new phones array.

Backend changes

  • Added a phones field to the user model and updated SaveUserData accordingly.
  • Updated user creation and update flows to handle multiple phone numbers.
  • Updated the users API to accept and process the phones array.
  • Included phones in user data query responses.

Frontend changes

  • Added a new PhoneNumberFieldList component to manage multiple phone numbers in forms, including validation and accessibility support.
  • Updated the account profile form to allow adding, editing, and removing phone numbers.
  • Updated UserInfo to display all phone numbers with their labels instead of a single phone field.

Tests

  • Added and updated tests for PhoneNumberFieldList, covering rendering, accessibility, interactions, validation, and snapshots.

These changes provide a more flexible way to manage user contact information while keeping the experience consistent across the application.

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Users can add, edit, and manage multiple phone numbers with optional labels and a primary flag; phone lists appear in profiles and admin user views.
    • Profile and admin forms include a Phone Numbers section with add/remove UI and validation; UI strings localized.
  • Tests

    • Added component, API, and end-to-end tests covering multi-phone creation, editing, removal, validation, and persistence.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 26, 2026

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

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 26, 2026

⚠️ No Changeset found

Latest commit: 416dc69

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

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: 97dfe0da-1063-4dc5-a437-a400ec460252

📥 Commits

Reviewing files that changed from the base of the PR and between bdc6ed8 and 416dc69.

⛔ Files ignored due to path filters (2)
  • apps/meteor/client/components/PhoneNumberFieldList/__snapshots__/PhoneNumberFieldList.spec.tsx.snap is excluded by !**/*.snap
  • apps/meteor/client/components/UserInfo/__snapshots__/UserInfo.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (14)
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.stories.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
  • apps/meteor/client/components/UserInfo/UserInfoPhoneNumberList.tsx
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • apps/meteor/client/views/account/profile/AccountProfilePage.tsx
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/i18n/src/locales/pt-BR.i18n.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
🧰 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:

  • apps/meteor/client/components/UserInfo/UserInfoPhoneNumberList.tsx
  • apps/meteor/client/views/account/profile/AccountProfilePage.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.stories.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
  • packages/model-typings/src/models/IUsersModel.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
apps/meteor/tests/e2e/page-objects/**/*.ts

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

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

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

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
🪛 ast-grep (0.43.0)
apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts

[warning] 14-14: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(^Label for phone number "${index + 1}"$)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)

🔇 Additional comments (7)
packages/model-typings/src/models/IUsersModel.ts (1)

407-407: LGTM!

apps/meteor/client/views/account/profile/AccountProfilePage.tsx (1)

127-127: LGTM!

apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts (1)

7-7: LGTM!

Also applies to: 15-15, 19-19, 31-31

packages/i18n/src/locales/en.i18n.json (1)

478-478: LGTM!

Also applies to: 2779-2779, 3039-3039, 4167-4167, 4493-4493

apps/meteor/client/components/UserInfo/UserInfo.tsx (1)

27-27: LGTM!

Also applies to: 171-173

apps/meteor/client/components/UserInfo/UserInfoPhoneNumberList.tsx (1)

1-24: LGTM!

apps/meteor/client/components/UserInfo/UserInfo.stories.tsx (1)

62-74: LGTM!


Walkthrough

This PR implements multi-phone number support across Rocket.Chat. Users can now have multiple phone numbers with optional labels and metadata (primary, verified flags). The legacy single phone field is deprecated in favor of a new phones array, with backward compatibility maintained through normalization logic in client-side display components.

Changes

Multi-phone Support Feature

Layer / File(s) Summary
Core Type System & Data Models
packages/core-typings/src/IUser.ts, packages/core-typings/src/IMeApiUser.ts
Adds IUserPhoneNumber interface with number, label, primary, and verified properties. Updates IUser to deprecate phone?: string and introduce phones?: IUserPhoneNumber[]. Extends IMeApiUser projection to include phones.
Database Model Layer
packages/model-typings/src/models/IUsersModel.ts, packages/models/src/models/Users.ts
Adds setPhones(userId, phones) interface method and implementation in UsersRaw that conditionally sets or unsets the phones field based on array content.
Server User Save & Profile Operations
apps/meteor/app/lib/server/functions/saveUser/saveUser.ts, apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts, apps/meteor/server/methods/saveUserProfile.ts
Updates SaveUserData type to include phones field. Implements phones handling in saveNewUser and saveUser functions. Adds phone update support in saveUserProfile method with proper DDP and exported function signature updates.
Server User Data Queries & Projections
apps/meteor/app/lib/server/functions/getFullUserData.ts, apps/meteor/app/utils/server/functions/getBaseUserFields.ts
Adds phones field to fullFields projection and base user fields for proper retrieval in user queries.
REST API Contracts & Validation
packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts, packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts, packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts, packages/rest-typings/src/v1/Ajv.ts
Extends REST parameter types with optional phones field. Adds JSON schema validation for phones array with required number (E.164 format), optional label (max 50 chars), and boolean metadata. Registers basic_phone_number AJV format validator.
API Route Update
apps/meteor/app/api/server/v1/users.ts
Updates users.updateOwnBasicInfo endpoint to accept and forward phones from request body.
Phone Input Component & Tests
apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx, apps/meteor/client/components/PhoneNumberFieldList/index.ts, apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
Creates generic PhoneNumberFieldList React component for managing dynamic phone arrays via react-hook-form. Includes E.164 phone validation, max-label-length constraint (50 chars), and per-phone add/remove UI. Comprehensive unit tests cover rendering, accessibility, user interactions, and validation scenarios.
Account Profile Form Integration
apps/meteor/client/views/account/profile/AccountProfileForm.tsx, apps/meteor/client/views/account/profile/getProfileInitialValues.ts
Wires PhoneNumberFieldList into account profile form using useFieldArray for dynamic phone list management. Form submission includes phones in payload to /v1/users.updateOwnBasicInfo. Initial values populate from user.phones with fallback from legacy user.phone.
Admin User Form Integration
apps/meteor/client/views/admin/users/AdminUserForm.tsx
Extends UserFormProps with optional phones field. Integrates PhoneNumberFieldList with useFieldArray for phone management in admin user creation/editing. Initializes phones from form data with legacy phone mapping.
Client-side Data Synchronization
apps/meteor/client/lib/userData.ts
Extends RawUserData to include phones field. Updates synchronizeUserData to extract phones from /v1/me response and propagate through Zustand store alongside existing profile fields.
User Display Components
apps/meteor/client/components/UserInfo/UserInfo.tsx, apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx, apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx
Updates UserInfo to display phones array with formatted numbers and optional labels as tags. Normalizes phones in container components with fallback from legacy phone field when phones is absent.
Omnichannel Template Selector Integration
apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx
Derives primary phone from user.phones with fallback sequence: primary-flagged phone, first phone, or legacy phone field.
Internationalization Strings
packages/i18n/src/locales/en.i18n.json, packages/i18n/src/locales/pt-BR.i18n.json
Adds English and Portuguese (pt-BR) i18n entries for generic invalid-field message, phone label display, phone input placeholders, and phone removal confirmation with label interpolation.
End-to-End Tests & Coverage
apps/meteor/tests/e2e/account-profile.spec.ts, apps/meteor/tests/e2e/admin-users-phones.spec.ts, apps/meteor/tests/end-to-end/api/users.ts
Adds E2E tests for account profile phone add/remove with persistence verification across page reloads. Admin UI E2E tests validate phone editing and removal flows. REST API tests cover /users.create, /users.info, /users.update, and /users.updateOwnBasicInfo with phones support, validation, and error cases.
E2E Test Infrastructure & Page Objects
apps/meteor/tests/e2e/page-objects/account-profile.ts, apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts, apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts, apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts, apps/meteor/tests/e2e/page-objects/fragments/index.ts
Adds PhoneNumberFieldList page object fragment with helpers for add/remove/set phone operations. Updates AccountProfile and EditUserFlexTab with phone field accessors. Adds phone link locators to UserInfoFlexTab for phone verification in info panels.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type: feature

Suggested reviewers

  • tassoevan
  • ricardogarim
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Add phone support to user' accurately describes the main change: replacing a single phone field with support for multiple phone numbers throughout the codebase.
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.

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


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 97.54601% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.80%. Comparing base (7af134c) to head (416dc69).
⚠️ Report is 20 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40697      +/-   ##
===========================================
+ Coverage    69.71%   69.80%   +0.09%     
===========================================
  Files         3339     3329      -10     
  Lines       123269   123283      +14     
  Branches     21971    22029      +58     
===========================================
+ Hits         85931    86061     +130     
+ Misses       33990    33859     -131     
- Partials      3348     3363      +15     
Flag Coverage Δ
e2e 59.39% <67.64%> (+0.14%) ⬆️
e2e-api 46.95% <100.00%> (+0.94%) ⬆️
unit 70.53% <100.00%> (-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.

@aleksandernsilva aleksandernsilva added this to the POC-VOICE milestone May 27, 2026
@aleksandernsilva
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the type: feature Pull requests that introduces new feature label May 29, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 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/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx`:
- Around line 45-51: The required validator in PhoneNumberFieldList's rules
currently calls value.trim() which throws if value is undefined; update the
required validator (inside rules.validate) to guard against undefined (e.g., use
optional chaining or a null check such as value?.trim() or typeof value ===
'string' before trimming) so validation returns the localized "Required_field"
message when value is missing instead of throwing a TypeError.

In `@apps/meteor/client/components/UserInfo/UserInfo.tsx`:
- Around line 174-185: The list uses phones.map in the UserInfo component with
key={p.number}, which can collide for entries sharing the same number; update
the map call to include the index (or another unique field) in the key to make
it collision-resistant—e.g., change the map callback signature to (p, i) and set
the key to a combined value such as `${p.number}-${i}` (or use p.id if
available) on the Box element that currently uses key={p.number}; this ensures
stable, unique keys for reconciliation while keeping formatPhoneNumber and the
existing JSX intact.

In `@apps/meteor/tests/e2e/account-profile.spec.ts`:
- Around line 97-99: The test clicks poAccountProfile.btnSaveChanges and
immediately calls page.reload(), causing a race; instead wait for a web-first
completion signal (e.g. the success toast used elsewhere) before reloading.
Update both occurrences (around the click at the first block and the one at
lines 122-124) to wait for the success toast or equivalent completion element
from poAccountProfile (e.g. poAccountProfile.toastSuccess or its selector) to be
visible/attached (or wait for the save button to become enabled/hidden) and only
then call page.reload() so the profile update has completed before assertions.

In `@apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts`:
- Around line 14-15: The locator in getPhoneLabelInput uses a loose regex that
can match "10" when index is 0; update the regex passed to this.root.getByRole
(used in getPhoneLabelInput) to match the exact indexed label (e.g., anchor the
pattern with an end anchor or word boundary so it only matches the specific
`${index + 1}`) so the locator targets the correct textbox even when there are
10+ phone rows.

In `@packages/i18n/src/locales/pt-BR.i18n.json`:
- Around line 4142-4143: Replace the current placeholder values for the locale
keys Phone_number_placeholder and Phone_label_placeholder to use pt-BR
abbreviation style "Ex.:" instead of "ex.,": update the string for
"Phone_number_placeholder" from "ex., +55 11 91234 5678" to "Ex.: +55 11 91234
5678" and update "Phone_label_placeholder" from "ex., Celular, Trabalho, Casa"
to "Ex.: Celular, Trabalho, Casa" so both keys follow pt-BR capitalization and
punctuation conventions.

In `@packages/model-typings/src/models/IUsersModel.ts`:
- Line 408: The interface IUsersModel.setPhones currently requires phones to be
non-optional but UsersRaw.setPhones accepts IUser['phones'] (which is optional)
and treats undefined as a clear/unset; update the IUsersModel declaration for
setPhones to accept an optional phones parameter (e.g. phones?:
IUserPhoneNumber[] or phones: IUser['phones']) so the API contract matches
UsersRaw.setPhones and existing callers like saveUserProfile that only call when
Array.isArray(settings.phones) continue to work; alternatively, add a separate
clearPhones method if you want an explicit clear operation.

In `@packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts`:
- Line 16: The TypeScript type for the `phones` property (`IUserPhoneNumber[]`
in the `UsersUpdateOwnBasicInfoParamsPOST` definition) does not match the JSON
schema used for runtime validation (lines 63-76) because the schema forbids
extra props like `verified`; either narrow the TS type to a shape that excludes
`verified` (create a new type/alias used in this DTO instead of
`IUserPhoneNumber`) or relax the schema to allow `verified` (remove
`additionalProperties: false` or explicitly include `verified` in the schema
object), and update the `phones` property reference accordingly so compile-time
and runtime contracts align (adjust the interfaces/types and the JSON schema
block where `phones` is defined).
🪄 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: 05506d1e-daba-41f1-aa15-ac7eb89fac05

📥 Commits

Reviewing files that changed from the base of the PR and between 7af134c and bdc6ed8.

⛔ Files ignored due to path filters (1)
  • apps/meteor/client/components/PhoneNumberFieldList/__snapshots__/PhoneNumberFieldList.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (35)
  • apps/meteor/app/api/server/v1/users.ts
  • apps/meteor/app/lib/server/functions/getFullUserData.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
  • apps/meteor/app/utils/server/functions/getBaseUserFields.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/components/PhoneNumberFieldList/index.ts
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
  • apps/meteor/client/lib/userData.ts
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
  • apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx
  • apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx
  • apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx
  • apps/meteor/server/methods/saveUserProfile.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/tests/end-to-end/api/users.ts
  • packages/core-typings/src/IMeApiUser.ts
  • packages/core-typings/src/IUser.ts
  • packages/i18n/src/locales/en.i18n.json
  • packages/i18n/src/locales/pt-BR.i18n.json
  • packages/model-typings/src/models/IUsersModel.ts
  • packages/models/src/models/Users.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/client/components/PhoneNumberFieldList/index.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
  • apps/meteor/app/lib/server/functions/getFullUserData.ts
  • apps/meteor/app/utils/server/functions/getBaseUserFields.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx
  • packages/core-typings/src/IUser.ts
  • packages/models/src/models/Users.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/app/api/server/v1/users.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
  • apps/meteor/client/lib/userData.ts
  • apps/meteor/tests/end-to-end/api/users.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • apps/meteor/server/methods/saveUserProfile.ts
  • apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx
  • packages/core-typings/src/IMeApiUser.ts
  • apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
apps/meteor/tests/e2e/page-objects/**/*.ts

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

Utilize existing page objects pattern from apps/meteor/tests/e2e/page-objects/

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}

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

apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests

Files:

  • apps/meteor/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • apps/meteor/tests/e2e/account-profile.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:

  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
apps/meteor/tests/e2e/**/*.spec.ts

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

apps/meteor/tests/e2e/**/*.spec.ts: All test files must be created in apps/meteor/tests/e2e/ directory
Avoid using page.locator() in Playwright tests - always prefer semantic locators such as page.getByRole(), page.getByLabel(), page.getByText(), or page.getByTitle()
Use test.beforeAll() and test.afterAll() for setup/teardown in Playwright tests
Use test.step() for complex test scenarios to improve organization in Playwright tests
Group related tests in the same file
Utilize Playwright fixtures (test, page, expect) for consistency in test files
Prefer web-first assertions (toBeVisible, toHaveText, etc.) in Playwright tests
Use expect matchers for assertions (toEqual, toContain, toBeTruthy, toHaveLength, etc.) instead of assert statements in Playwright tests
Use page.waitFor() with specific conditions instead of hardcoded timeouts in Playwright tests
Implement proper wait strategies for dynamic content in Playwright tests
Maintain test isolation between test cases in Playwright tests
Ensure clean state for each test execution in Playwright tests
Ensure tests run reliably in parallel without shared state conflicts

Files:

  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
🧠 Learnings (16)
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
📚 Learning: 2026-02-24T19:39:42.247Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/message.ts:7-7
Timestamp: 2026-02-24T19:39:42.247Z
Learning: In RocketChat e2e tests, avoid using data-qa attributes to locate elements. Prefer semantic locators such as getByRole, getByLabel, getByText, getByTitle and ARIA-based selectors. Apply this rule to all TypeScript files under apps/meteor/tests/e2e to improve test reliability, accessibility, and maintainability.

Applied to files:

  • apps/meteor/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • apps/meteor/tests/e2e/account-profile.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 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/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/client/components/PhoneNumberFieldList/index.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
  • apps/meteor/app/lib/server/functions/getFullUserData.ts
  • apps/meteor/app/utils/server/functions/getBaseUserFields.ts
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • packages/core-typings/src/IUser.ts
  • packages/models/src/models/Users.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/app/api/server/v1/users.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • apps/meteor/client/lib/userData.ts
  • apps/meteor/tests/end-to-end/api/users.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • apps/meteor/server/methods/saveUserProfile.ts
  • packages/core-typings/src/IMeApiUser.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/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/client/components/PhoneNumberFieldList/index.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
  • apps/meteor/app/lib/server/functions/getFullUserData.ts
  • apps/meteor/app/utils/server/functions/getBaseUserFields.ts
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • packages/core-typings/src/IUser.ts
  • packages/models/src/models/Users.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/app/api/server/v1/users.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • apps/meteor/client/lib/userData.ts
  • apps/meteor/tests/end-to-end/api/users.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • apps/meteor/server/methods/saveUserProfile.ts
  • packages/core-typings/src/IMeApiUser.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/tests/e2e/page-objects/fragments/index.ts
  • apps/meteor/client/components/PhoneNumberFieldList/index.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveUser.ts
  • apps/meteor/app/lib/server/functions/getFullUserData.ts
  • apps/meteor/app/utils/server/functions/getBaseUserFields.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • apps/meteor/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/page-objects/account-profile.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/user-info-flextab.ts
  • apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts
  • apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts
  • apps/meteor/tests/e2e/page-objects/fragments/flextabs/edit-user-flextab.ts
  • apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx
  • packages/core-typings/src/IUser.ts
  • packages/models/src/models/Users.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/app/api/server/v1/users.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
  • apps/meteor/client/lib/userData.ts
  • apps/meteor/tests/end-to-end/api/users.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts
  • packages/model-typings/src/models/IUsersModel.ts
  • apps/meteor/server/methods/saveUserProfile.ts
  • apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx
  • packages/core-typings/src/IMeApiUser.ts
  • apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
📚 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/components/PhoneNumberFieldList/index.ts
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • apps/meteor/client/lib/userData.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/components/PhoneNumberFieldList/index.ts
  • apps/meteor/client/views/account/profile/getProfileInitialValues.ts
  • apps/meteor/client/lib/userData.ts
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.

Applied to files:

  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx
  • apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
  • apps/meteor/client/views/admin/users/AdminUserForm.tsx
  • apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx
  • apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx
  • apps/meteor/client/views/account/profile/AccountProfileForm.tsx
  • apps/meteor/client/components/UserInfo/UserInfo.tsx
📚 Learning: 2026-05-11T23:14:59.316Z
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 40469
File: packages/rest-typings/src/v1/users.ts:337-337
Timestamp: 2026-05-11T23:14:59.316Z
Learning: In Rocket.Chat REST endpoint typings (e.g., packages/rest-typings/src/v1/users.ts and other rest-typings files), keep the established convention of deriving field types from the domain model (e.g., use IUser indexed access like IUser['statusExpiresAt']) rather than swapping individual fields to serialized primitives (like string) in an ad-hoc way. If a truly different “serialized” representation is needed, perform the refactor consistently across the codebase (not just a single endpoint/field) and ensure all related REST typings stay aligned with the shared serialization types.

Applied to files:

  • packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts
  • packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts
  • packages/rest-typings/src/v1/Ajv.ts
  • packages/rest-typings/src/v1/users/UserCreateParamsPOST.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/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/account-profile.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/tests/e2e/admin-users-phones.spec.ts
  • apps/meteor/tests/e2e/account-profile.spec.ts
  • apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.

Applied to files:

  • apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.

Applied to files:

  • apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-15T14:31:25.380Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:25.380Z
Learning: Do not flag this type/schema misalignment in the OpenAPI/migration review for apps/meteor/app/api/server/v1/users.ts. The UserCreateParamsPOST type intentionally uses non-optional fields: fields: string and settings?: IUserSettings without an AJV schema entry, carried over from the original rest-typings (PR `#39647`). Treat this as a known pre-existing divergence and document it as a separate follow-up fix; do not block or mark it as a review issue during the migration.

Applied to files:

  • apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-16T23:33:11.443Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: apps/meteor/app/api/server/v1/users.ts:862-869
Timestamp: 2026-03-16T23:33:11.443Z
Learning: In rockets OpenAPI/AJV migration reviews for RocketChat/Rocket.Chat, when reviewing migrations that involve apps/meteor/app/api/server/v1/users.ts, do not require or flag a missing query AJV schema for the fields consumed by parseJsonQuery() (i.e., fields, sort, query) as part of this endpoint's migration PR. The addition of global query-param schemas for parseJsonQuery() usage is a cross-cutting concern and out of scope for individual endpoint migrations. Only flag violations related to the specific scope of the migration, not the absence of a query schema for parseJsonQuery() in this file.

Applied to files:

  • apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-09T18:39:14.020Z
Learnt from: Harxhit
Repo: RocketChat/Rocket.Chat PR: 39476
File: apps/meteor/server/methods/addAllUserToRoom.ts:0-0
Timestamp: 2026-03-09T18:39:14.020Z
Learning: When implementing batch processing in server methods, favor a single data pass to collect both the items and any derived fields needed for validation. Use the same dataset for both validation and processing to avoid races between validation and execution, and document the approach in code comments. Apply this pattern to similar Meteor Rocket.Chat server methods under apps/meteor/server/methods to prevent race conditions and ensure consistent batch behavior.

Applied to files:

  • apps/meteor/server/methods/saveUserProfile.ts
🪛 ast-grep (0.42.3)
apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts

[warning] 14-14: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(Label for phone.*${index + 1})
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)

🔇 Additional comments (28)
packages/rest-typings/src/v1/users/UserCreateParamsPOST.ts (1)

1-1: LGTM!

Also applies to: 23-23, 48-62

packages/rest-typings/src/v1/users/UsersUpdateParamsPOST.ts (1)

1-1: LGTM!

Also applies to: 26-26, 111-125

apps/meteor/app/api/server/v1/users.ts (1)

204-204: LGTM!

packages/core-typings/src/IUser.ts (2)

155-160: LGTM!


211-215: LGTM!

packages/core-typings/src/IMeApiUser.ts (1)

28-28: LGTM!

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

3057-3060: LGTM!

packages/rest-typings/src/v1/Ajv.ts (1)

28-28: LGTM!

Also applies to: 34-34

apps/meteor/app/lib/server/functions/saveUser/saveUser.ts (2)

57-57: LGTM!


186-192: ⚖️ Poor tradeoff

Document/guard phone verified updates in saveUser

  • saveUserProfile strips verified from each phone before calling Users.setPhones(...) (apps/meteor/server/methods/saveUserProfile.ts around line 125).
  • saveUser updates phones from userData.phones without removing verified (apps/meteor/app/lib/server/functions/saveUser/saveUser.ts lines 186-192).
    Ensure saveUser is restricted to callers allowed to set phone verification state (or strip verified there as well) and document the intended security model.
apps/meteor/app/lib/server/functions/saveUser/saveNewUser.ts (1)

58-60: LGTM!

apps/meteor/server/methods/saveUserProfile.ts (2)

2-2: LGTM!

Also applies to: 37-37, 228-228, 248-248


122-131: LGTM!

apps/meteor/app/lib/server/functions/getFullUserData.ts (1)

31-31: LGTM!

apps/meteor/app/utils/server/functions/getBaseUserFields.ts (1)

10-10: LGTM!

apps/meteor/client/lib/userData.ts (1)

18-18: LGTM!

Also applies to: 92-92, 165-166

apps/meteor/client/components/UserInfo/UserInfo.tsx (1)

27-27: LGTM!

Also applies to: 39-39, 68-68

apps/meteor/client/views/admin/users/AdminUserInfoWithData.tsx (1)

59-60: LGTM!

Also applies to: 75-76, 86-86

apps/meteor/client/views/room/contextualBar/UserInfo/UserInfoWithData.tsx (1)

65-66: LGTM!

Also applies to: 73-74, 87-87

apps/meteor/client/views/omnichannel/components/outboundMessage/components/TemplatePlaceholderSelector/hooks/useAgentSection.tsx (1)

32-37: LGTM!

apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx (1)

1-44: LGTM!

Also applies to: 52-105

apps/meteor/client/components/PhoneNumberFieldList/index.ts (1)

1-2: LGTM!

apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.spec.tsx (1)

1-179: LGTM!

apps/meteor/client/views/account/profile/AccountProfileForm.tsx (1)

19-19: LGTM!

Also applies to: 24-24, 102-141, 311-326

apps/meteor/client/views/account/profile/getProfileInitialValues.ts (1)

1-1: LGTM!

Also applies to: 16-16, 30-30

apps/meteor/client/views/admin/users/AdminUserForm.tsx (1)

1-1: LGTM!

Also applies to: 34-34, 43-43, 58-61, 89-89, 129-129, 533-547

packages/i18n/src/locales/en.i18n.json (1)

2778-2778: LGTM!

Also applies to: 3038-3038, 4170-4171, 4492-4492

packages/i18n/src/locales/pt-BR.i18n.json (1)

2764-2764: LGTM!

Also applies to: 3012-3012, 4465-4465

Comment thread apps/meteor/client/components/UserInfo/UserInfo.tsx Outdated
Comment thread apps/meteor/tests/e2e/account-profile.spec.ts
Comment thread apps/meteor/tests/e2e/page-objects/fragments/phone-number-field-list.ts Outdated
Comment thread packages/i18n/src/locales/pt-BR.i18n.json Outdated
Comment thread packages/model-typings/src/models/IUsersModel.ts Outdated
Comment thread packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts Outdated
@aleksandernsilva aleksandernsilva marked this pull request as ready for review June 1, 2026 20:15
@aleksandernsilva aleksandernsilva requested review from a team as code owners June 1, 2026 20:15
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

4 issues found across 40 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/client/views/account/profile/AccountProfileForm.tsx">

<violation number="1" location="apps/meteor/client/views/account/profile/AccountProfileForm.tsx:320">
P3: Passing `useFieldArray().fields` as value data causes stale phone labels in accessibility text (remove button `aria-label` won’t track edits).</violation>
</file>

<file name="apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx">

<violation number="1" location="apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx:8">
P2: `E164_PHONE_REGEX` allows numbers without a leading `+`, so non-E.164 values are accepted as valid.</violation>
</file>

<file name="apps/meteor/client/lib/userData.ts">

<violation number="1" location="apps/meteor/client/lib/userData.ts:165">
P2: `phones` is assigned unconditionally and can clear existing phone data when `/v1/me` does not include the field.</violation>
</file>

<file name="apps/meteor/server/methods/saveUserProfile.ts">

<violation number="1" location="apps/meteor/server/methods/saveUserProfile.ts:125">
P2: `phones` items are not validated before object destructuring, which can throw on malformed array entries.</violation>
</file>

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

Re-trigger cubic

import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/;
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.

P2: E164_PHONE_REGEX allows numbers without a leading +, so non-E.164 values are accepted as valid.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/components/PhoneNumberFieldList/PhoneNumberFieldList.tsx, line 8:

<comment>`E164_PHONE_REGEX` allows numbers without a leading `+`, so non-E.164 values are accepted as valid.</comment>

<file context>
@@ -0,0 +1,98 @@
+import { Controller } from 'react-hook-form';
+import { useTranslation } from 'react-i18next';
+
+const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/;
+const MAX_PHONE_NUMBER_LABEL_LENGTH = 50;
+
</file context>
Suggested change
const E164_PHONE_REGEX = /^\+?[1-9]\d{1,14}$/;
const E164_PHONE_REGEX = /^\+[1-9]\d{1,14}$/;

ldap: Boolean(ldap),
createdAt: meFields.createdAt != null ? new Date(meFields.createdAt) : (existingUser?.createdAt ?? new Date()),
_updatedAt: new Date(meFields._updatedAt ?? existingUser?._updatedAt ?? Date.now()),
phones,
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.

P2: phones is assigned unconditionally and can clear existing phone data when /v1/me does not include the field.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/lib/userData.ts, line 165:

<comment>`phones` is assigned unconditionally and can clear existing phone data when `/v1/me` does not include the field.</comment>

<file context>
@@ -161,6 +162,7 @@ export const synchronizeUserData = async (uid: IUser['_id']): Promise<RawUserDat
 			ldap: Boolean(ldap),
 			createdAt: meFields.createdAt != null ? new Date(meFields.createdAt) : (existingUser?.createdAt ?? new Date()),
 			_updatedAt: new Date(meFields._updatedAt ?? existingUser?._updatedAt ?? Date.now()),
+			phones,
 		} as IUser);
 	}
</file context>
Suggested change
phones,
phones: phones ?? existingUser?.phones,

if (Array.isArray(settings.phones)) {
await Users.setPhones(
user._id,
settings.phones.map(({ verified: _, ...phone }) => phone),
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.

P2: phones items are not validated before object destructuring, which can throw on malformed array entries.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/server/methods/saveUserProfile.ts, line 125:

<comment>`phones` items are not validated before object destructuring, which can throw on malformed array entries.</comment>

<file context>
@@ -118,6 +119,17 @@ async function saveUserProfile(
+	if (Array.isArray(settings.phones)) {
+		await Users.setPhones(
+			user._id,
+			settings.phones.map(({ verified: _, ...phone }) => phone),
+		);
+
</file context>
Suggested change
settings.phones.map(({ verified: _, ...phone }) => phone),
settings.phones.map((entry) => {
if (!entry || typeof entry !== 'object' || typeof entry.number !== 'string') {
throw new Meteor.Error('error-invalid-field', 'phones', {
method: 'saveUserProfile',
});
}
const { verified: _, ...phone } = entry;
return phone;
}),

<PhoneNumberFieldList
control={control}
name='phones'
phones={phoneFields}
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.

P3: Passing useFieldArray().fields as value data causes stale phone labels in accessibility text (remove button aria-label won’t track edits).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/views/account/profile/AccountProfileForm.tsx, line 320:

<comment>Passing `useFieldArray().fields` as value data causes stale phone labels in accessibility text (remove button `aria-label` won’t track edits).</comment>

<file context>
@@ -290,6 +308,22 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
+						<PhoneNumberFieldList
+							control={control}
+							name='phones'
+							phones={phoneFields}
+							onAddPhone={appendPhone}
+							onRemovePhone={removePhone}
</file context>

ggazzo pushed a commit that referenced this pull request Jun 2, 2026
ggazzo pushed a commit that referenced this pull request Jun 3, 2026
ggazzo pushed a commit that referenced this pull request Jun 3, 2026
ggazzo pushed a commit that referenced this pull request Jun 3, 2026
ggazzo pushed a commit that referenced this pull request Jun 3, 2026
ggazzo pushed a commit that referenced this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-to-poc type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants