Skip to content

refactor: Use WHATWG URL instead of node url/querystring - #41529

Merged
dionisio-bot[bot] merged 5 commits into
developfrom
refactor/e2ee-url
Jul 23, 2026
Merged

refactor: Use WHATWG URL instead of node url/querystring#41529
dionisio-bot[bot] merged 5 commits into
developfrom
refactor/e2ee-url

Conversation

@tassoevan

@tassoevan tassoevan commented Jul 23, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

The node:url and node:querystring modules are unavailable outside the Meteor bundle. This replaces their usage in parseQuoteAttachment with the standard WHATWG URL API, and removes the now-unused client import symlinks that were only kept to satisfy those legacy imports.

No behavior change — purely a refactor.

Issue(s)

Steps to test or reproduce

  1. Send/receive an E2EE message containing a quoted attachment link.
  2. Confirm the quote attachment parses and renders correctly.

Further comments

🤖 Generated with Claude Code

Review in cubic

Task: ARCH-2293

Summary by CodeRabbit

  • Bug Fixes
    • Improved quoted-message link parsing for the secure chat flow, using safer URL handling.
    • The app now skips malformed or ambiguous quoted-message links, preventing incorrect fetching/decryption.
  • Chores
    • Removed obsolete client-side package reference/link entries that were no longer present.

cardoso and others added 2 commits July 23, 2026 01:11
The node:url and node:querystring modules are unavailable outside the
Meteor bundle; parseQuoteAttachment now uses the standard URL API.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tassoevan
tassoevan requested a review from a team as a code owner July 23, 2026 04:44
@dionisio-bot

dionisio-bot Bot commented Jul 23, 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 Jul 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b60ba0c

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

@tassoevan tassoevan added this to the 8.8.0 milestone Jul 23, 2026
@tassoevan

Copy link
Copy Markdown
Member Author

/jira ARCH-2086

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cee4a4c3-ddac-4b7c-ad70-6c85c8ffa501

📥 Commits

Reviewing files that changed from the base of the PR and between 60b3f68 and b60ba0c.

📒 Files selected for processing (1)
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build

Walkthrough

The E2EE quote attachment parser removes Node-specific URL and querystring imports, uses the global URL API, skips malformed URLs, and proceeds only when exactly one quoted message ID is present.

Changes

E2EE quote attachment parsing

Layer / File(s) Summary
Global URL parsing for quoted messages
apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
Replaces Node-specific parsing with URL.searchParams, skips malformed URLs, and continues only when exactly one msg value is present.

Estimated code review effort: 2 (Simple) | ~5 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 summarizes the main refactor from Node URL/querystring usage to WHATWG URL.
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.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • ARCH-2293: 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/client/lib/e2ee/rocketchat.e2e.ts`:
- Around line 737-739: Update the URL message-parameter handling near the msgId
extraction to use urlObj.searchParams.getAll('msg') instead of
Object.fromEntries. Require exactly one msg value before fetching the quoted
message, preserving the existing skip behavior when the parameter is missing or
duplicated.
🪄 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 Plus

Run ID: bbf56111-4396-4b82-a677-b6b607cc58db

📥 Commits

Reviewing files that changed from the base of the PR and between e46a00f and eb0412d.

📒 Files selected for processing (14)
  • apps/meteor/client/lib/e2ee/rocketchat.e2e.ts
  • apps/meteor/imports/client/hepburn
  • apps/meteor/imports/client/limax
  • apps/meteor/imports/client/map-age-cleaner
  • apps/meteor/imports/client/mem
  • apps/meteor/imports/client/mimic-fn/index.js
  • apps/meteor/imports/client/p-defer
  • apps/meteor/imports/client/poly1305-js
  • apps/meteor/imports/client/query-string
  • apps/meteor/imports/client/scheduler
  • apps/meteor/imports/client/sodium-native
  • apps/meteor/imports/client/sodium-plus
  • apps/meteor/imports/client/split-on-first
  • apps/meteor/imports/client/strict-uri-encode
💤 Files with no reviewable changes (13)
  • apps/meteor/imports/client/map-age-cleaner
  • apps/meteor/imports/client/sodium-plus
  • apps/meteor/imports/client/strict-uri-encode
  • apps/meteor/imports/client/limax
  • apps/meteor/imports/client/hepburn
  • apps/meteor/imports/client/mem
  • apps/meteor/imports/client/poly1305-js
  • apps/meteor/imports/client/mimic-fn/index.js
  • apps/meteor/imports/client/scheduler
  • apps/meteor/imports/client/query-string
  • apps/meteor/imports/client/sodium-native
  • apps/meteor/imports/client/p-defer
  • apps/meteor/imports/client/split-on-first
📜 Review details
⏰ Context from checks skipped due to timeout. (5)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: Hacktron Security Check
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{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/lib/e2ee/rocketchat.e2e.ts
🧠 Learnings (5)
📚 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/lib/e2ee/rocketchat.e2e.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/lib/e2ee/rocketchat.e2e.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/client/lib/e2ee/rocketchat.e2e.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/client/lib/e2ee/rocketchat.e2e.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/client/lib/e2ee/rocketchat.e2e.ts
🔇 Additional comments (2)
apps/meteor/client/lib/e2ee/rocketchat.e2e.ts (2)

1-2: LGTM!


731-735: 🩺 Stability & Availability

Prevent malformed URLs from rejecting quote parsing.

new URL(url) throws for an invalid or non-absolute match. Because this runs inside Promise.all, one malformed URL can reject the entire parseQuoteAttachment call. Verify that getMessageUrlRegex() guarantees constructor-compatible URLs; otherwise catch the error and skip that match.

Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated
@tassoevan tassoevan changed the title refactor(e2ee): use WHATWG URL instead of node url/querystring refactor: Use WHATWG URL instead of node url/querystring Jul 23, 2026

@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 14 files

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

Re-trigger cubic

Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated
Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated
Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.63%. Comparing base (e46a00f) to head (b60ba0c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #41529   +/-   ##
========================================
  Coverage    68.63%   68.63%           
========================================
  Files         4138     4138           
  Lines       158963   158958    -5     
  Branches     27895    27915   +20     
========================================
- Hits        109098   109097    -1     
+ Misses       44724    44713   -11     
- Partials      5141     5148    +7     
Flag Coverage Δ
e2e 58.86% <75.00%> (-0.02%) ⬇️
e2e-api 45.37% <ø> (+0.03%) ⬆️
unit 70.64% <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.

tassoevan and others added 2 commits July 23, 2026 01:56
Read the msg query parameter via searchParams.getAll and skip fetching
when it is missing or duplicated, restoring the intended guard that the
previous Object.fromEntries collapse made unreachable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
new URL() throws on malformed input, unlike the previous URL.parse().
Since quote URLs come from regex-matched message content, one bad match
rejected the whole Promise.all and dropped every quote attachment. Parse
inside a try/catch and skip only the offending URL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated

@hacktron-app hacktron-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 issue found across 1 file

Severity Count
MEDIUM 1

View full scan results

Comment thread apps/meteor/client/lib/e2ee/rocketchat.e2e.ts Outdated
getAll('msg') returns [""] for ?msg=, which passed the length check and
reached chat.getMessage with an empty id (400 error). Guard against
missing, empty, or duplicated msg values in a single check.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tassoevan tassoevan added the stat: QA assured Means it has been tested and approved by a company insider label Jul 23, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Jul 23, 2026
@dionisio-bot
dionisio-bot Bot added this pull request to the merge queue Jul 23, 2026
Merged via the queue into develop with commit abd22bd Jul 23, 2026
56 checks passed
@dionisio-bot
dionisio-bot Bot deleted the refactor/e2ee-url branch July 23, 2026 20:13
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