Skip to content

refactor: remove uuid package#37143

Merged
kodiakhq[bot] merged 15 commits intoRocketChat:developfrom
AnastasiyaHladina:refactor/remove-uuid-package
Jan 31, 2026
Merged

refactor: remove uuid package#37143
kodiakhq[bot] merged 15 commits intoRocketChat:developfrom
AnastasiyaHladina:refactor/remove-uuid-package

Conversation

@AnastasiyaHladina
Copy link
Contributor

@AnastasiyaHladina AnastasiyaHladina commented Oct 5, 2025

Proposed changes (including videos or screenshots)

This PR removes the uuid package usage and replaces it with the crypto module that was added to Node.js.

Summary by CodeRabbit

  • Refactor
    • Standardized native ID generation across settings, OAuth, session/room handling, and account services; no user-facing behavior changes.
  • Chores
    • Removed legacy third-party UUID packages from project dependencies.
  • Tests
    • Updated test utilities and coverage filename generation to use the native ID method.

No functional or UX changes expected.

✏️ Tip: You can customize this high-level summary in your review settings.

@AnastasiyaHladina AnastasiyaHladina requested review from a team as code owners October 5, 2025 16:45
@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Oct 5, 2025

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

  • This PR is targeting the wrong base branch. It should target 8.2.0, but it targets 8.1.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Oct 5, 2025

⚠️ No Changeset found

Latest commit: e461ad4

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

@CLAassistant
Copy link

CLAassistant commented Oct 5, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 5, 2025

Walkthrough

Replaced uses of the external uuid library with crypto.randomUUID() across server, client, and test code; removed uuid (and @types/uuid) from package dependencies. Imports updated; no public APIs, control flow, or error handling changed.

Changes

Cohort / File(s) Summary
UUID -> crypto.randomUUID (code)
apps/meteor/app/api/server/v1/misc.ts, apps/meteor/app/apps/server/bridges/oauthApps.ts, apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts, apps/meteor/server/settings/misc.ts, ee/apps/account-service/src/lib/utils.ts, apps/meteor/tests/e2e/utils/test.ts
Replaced uuidv4() / uuid.v4() usage with crypto.randomUUID() (or randomUUID import). Removed uuid imports; updated ID/token/filename generation sites. No behavior or control-flow changes.
Dependencies cleanup
apps/meteor/package.json, apps/meteor/ee/server/services/package.json, ee/apps/account-service/package.json
Removed uuid (and @types/uuid where present) from dependencies/devDependencies.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump a tiny, cheerful beat,
old UUIDs swept from the street.
crypto seeds sprout quick and bright,
new IDs hopping out of sight.
Hooray — my burrow’s tidy and neat! 🥕🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: remove uuid package' directly and clearly summarizes the main change across the entire changeset, which involves removing the uuid package dependency and replacing all its usages with the built-in crypto.randomUUID() method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
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: 1

🧹 Nitpick comments (3)
ee/apps/account-service/src/lib/utils.ts (1)

1-5: Consolidate crypto imports.

The crypto module is imported twice. Consolidate into a single import statement for cleaner code.

Apply this diff:

-import crypto from 'crypto';
+import crypto, { randomUUID } from 'crypto';
 
 import { convertFromDaysToMilliseconds } from '@rocket.chat/tools';
 import bcrypt from 'bcrypt';
-import { randomUUID } from 'crypto';
apps/meteor/app/api/server/v1/misc.ts (1)

1-1: Consolidate crypto imports.

The crypto module is imported twice. Consolidate into a single import statement for cleaner code.

Apply this diff:

-import crypto from 'crypto';
+import crypto, { randomUUID } from 'crypto';
 
 import type { IUser } from '@rocket.chat/core-typings';

And remove the duplicate import on line 19:

 import { Meteor } from 'meteor/meteor';
-import { randomUUID } from 'crypto';
 
 import { i18n } from '../../../../server/lib/i18n';

Also applies to: 19-19

apps/meteor/server/settings/misc.ts (1)

1-5: Consolidate crypto imports.

The crypto module is imported twice. Consolidate into a single import statement for cleaner code.

Apply this diff:

-import crypto from 'crypto';
+import crypto, { randomUUID } from 'crypto';
 
 import { Logger } from '@rocket.chat/logger';
 import { Settings } from '@rocket.chat/models';
-import { randomUUID } from 'crypto';
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f627e67 and d4086b6.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • apps/meteor/app/api/server/v1/misc.ts (2 hunks)
  • apps/meteor/app/apps/server/bridges/oauthApps.ts (2 hunks)
  • apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts (2 hunks)
  • apps/meteor/ee/server/services/package.json (0 hunks)
  • apps/meteor/package.json (0 hunks)
  • apps/meteor/server/settings/misc.ts (2 hunks)
  • apps/meteor/tests/e2e/utils/test.ts (2 hunks)
  • ee/apps/account-service/package.json (1 hunks)
  • ee/apps/account-service/src/lib/utils.ts (2 hunks)
💤 Files with no reviewable changes (2)
  • apps/meteor/ee/server/services/package.json
  • apps/meteor/package.json
🧰 Additional context used
📓 Path-based instructions (2)
apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}

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

apps/meteor/tests/e2e/**/*.{ts,tsx,js,jsx}: Write concise, technical TypeScript/JavaScript with accurate typing
Follow DRY by extracting reusable logic into helper functions or page objects
Avoid code comments in the implementation

Files:

  • apps/meteor/tests/e2e/utils/test.ts
apps/meteor/tests/e2e/**/*.{ts,tsx}

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

apps/meteor/tests/e2e/**/*.{ts,tsx}: Avoid using page.locator(); prefer semantic locators like page.getByRole, page.getByLabel, page.getByText, and page.getByTitle
Store commonly used locators in variables/constants for reuse
Use page.waitFor() with specific conditions and avoid hardcoded timeouts
Implement proper wait strategies for dynamic content
Follow the Page Object Model pattern consistently

Files:

  • apps/meteor/tests/e2e/utils/test.ts
🔇 Additional comments (6)
apps/meteor/app/apps/server/bridges/oauthApps.ts (1)

7-7: LGTM! Clean migration to built-in crypto.

The replacement of uuid.v4() with crypto.randomUUID() is correct for this server-side code. Both generate RFC 4122 version 4 UUIDs.

Also applies to: 28-28

ee/apps/account-service/src/lib/utils.ts (1)

36-36: LGTM! Token generation updated correctly.

The replacement of uuid.v4() with randomUUID() for login token generation is correct.

ee/apps/account-service/package.json (1)

40-40: LGTM! Dependency removal aligns with code changes.

The removal of the uuid dependency is correct and consistent with the migration to Node.js's built-in crypto.randomUUID().

apps/meteor/tests/e2e/utils/test.ts (1)

8-8: LGTM! Test code correctly uses Node.js crypto.

This E2E test code runs in Node.js via Playwright, so using crypto.randomUUID() is appropriate and correct.

Also applies to: 57-57

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

684-684: LGTM! Deployment ID fallback updated correctly.

The replacement of uuid.v4() with randomUUID() for the uniqueID fallback value is correct.

apps/meteor/server/settings/misc.ts (1)

64-64: LGTM! Deployment ID generation updated correctly.

The replacement of uuid.v4() with randomUUID() for the uniqueID setting default is correct.

Copy link
Member

@cardoso cardoso left a comment

Choose a reason for hiding this comment

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

Thanks for this PR!

You should just use the global crypto.randomUUID instead of importing from 'crypto'.

There are incompatibilities between the server (Node) and client (Browser) when using the crypto global, but not for this particular API since we can ignore the optional argument node accepts.

@AnastasiyaHladina
Copy link
Contributor Author

Hello @cardoso
I've updated the PR please take a look.

@cardoso
Copy link
Member

cardoso commented Oct 8, 2025

@AnastasiyaHladina you need to run yarn lint and fix the errors.

@AnastasiyaHladina
Copy link
Contributor Author

@cardoso, updated, please check.

@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.40%. Comparing base (5cd511f) to head (e461ad4).
⚠️ Report is 247 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37143      +/-   ##
===========================================
- Coverage    70.41%   70.40%   -0.01%     
===========================================
  Files         3161     3161              
  Lines       110151   110151              
  Branches     19850    19892      +42     
===========================================
- Hits         77560    77554       -6     
- Misses       30560    30562       +2     
- Partials      2031     2035       +4     
Flag Coverage Δ
e2e 60.34% <100.00%> (+0.02%) ⬆️
e2e-api 47.79% <100.00%> (ø)
unit 71.43% <ø> (-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.

cardoso
cardoso previously approved these changes Oct 13, 2025
Copy link
Member

@cardoso cardoso left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks a lot for this PR!

May need reviews from @RocketChat/backend @RocketChat/apps and @RocketChat/frontend .

PS: Just one test failed but it seems flaky, so I just restarted it.

@AnastasiyaHladina
Copy link
Contributor Author

Looks good to me. Thanks a lot for this PR!

May need reviews from @RocketChat/backend @RocketChat/apps and @RocketChat/frontend .

PS: Just one test failed but it seems flaky, so I just restarted it.

@cardoso, any action expected from me?

@cardoso
Copy link
Member

cardoso commented Oct 22, 2025

Looks good to me. Thanks a lot for this PR!

May need reviews from @RocketChat/backend @RocketChat/apps and @RocketChat/frontend .

PS: Just one test failed but it seems flaky, so I just restarted it.

@cardoso, any action expected from me?

@AnastasiyaHladina not really, it should be merged once all reviews have been made. We're short on reviewers currently due to in-person events this month.

d-gubert
d-gubert previously approved these changes Oct 22, 2025
@d-gubert d-gubert added this to the 7.13.0 milestone Nov 5, 2025
@scuciatto scuciatto modified the milestones: 7.13.0, 7.14.0 Nov 19, 2025
@scuciatto scuciatto removed this from the 7.14.0 milestone Dec 18, 2025
@KevLehman
Copy link
Member

Thanks for the contrib! Can you pls fix the conflict? 👀

@AnastasiyaHladina
Copy link
Contributor Author

Thanks for the contrib! Can you pls fix the conflict? 👀

@KevLehman, fixed.

@KevLehman KevLehman requested a review from cardoso January 23, 2026 19:22
@tassoevan tassoevan added this to the 8.2.0 milestone Jan 23, 2026
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label Jan 23, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 23, 2026
@kodiakhq kodiakhq bot merged commit 7d89aae into RocketChat:develop Jan 31, 2026
43 checks passed
@dougfabris dougfabris added valid A valid contribution where maintainers will review based on priority labels Feb 3, 2026
Rohit3523 pushed a commit that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community 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 valid A valid contribution where maintainers will review based on priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants