Skip to content

Conversation

@MarcosSpessatto
Copy link
Contributor

@MarcosSpessatto MarcosSpessatto commented Apr 10, 2025

Introduced by #35078

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments


Description

This pull request addresses a regression issue where incoming integrations were not functioning correctly with the new hono router in the Rocket.Chat application. The changes are made in the following files:

  1. apps/meteor/app/api/server/router.ts:

    • Modifications are made to the body parameter parsing logic within the Router class. The focus is on handling override parameters and cases where the body is empty.
  2. apps/meteor/app/integrations/server/api/api.js:

    • Updates are implemented for webhook request handling, emphasizing asynchronous body parsing using modern JavaScript features.
    • URL construction is improved using the standard URL API and the x-forwarded-proto header.
    • Refinements are made to the header and body data passed to integration scripts.
    • Middleware is adjusted to handle application/x-www-form-urlencoded payloads that contain JSON.

These changes aim to enhance the functionality and reliability of incoming integrations with the new router setup.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 10, 2025

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

@changeset-bot
Copy link

changeset-bot bot commented Apr 10, 2025

⚠️ No Changeset found

Latest commit: 376f7a5

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

@codecov
Copy link

codecov bot commented Apr 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 61.01%. Comparing base (f22a6db) to head (376f7a5).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #35772   +/-   ##
========================================
  Coverage    61.01%   61.01%           
========================================
  Files         3099     3099           
  Lines        73248    73248           
  Branches     16398    16398           
========================================
+ Hits         44690    44693    +3     
  Misses       25534    25534           
+ Partials      3024     3021    -3     
Flag Coverage Δ
e2e 57.65% <ø> (+<0.01%) ⬆️
unit 75.49% <ø> (ø)

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.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 10, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35772/

Built to branch gh-pages at 2025-04-15 11:45 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@MarcosSpessatto MarcosSpessatto marked this pull request as ready for review April 11, 2025 12:41
@MarcosSpessatto MarcosSpessatto requested a review from ggazzo April 11, 2025 12:41
@MarcosSpessatto MarcosSpessatto marked this pull request as draft April 11, 2025 15:08
@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

Comment on lines +91 to +95
const buffers = [];
for await (const chunk of this.request.body) {
buffers.push(chunk);
}
const content_raw = Buffer.concat(buffers).toString('utf8');
Copy link

Choose a reason for hiding this comment

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

kody code-review Performance and Optimization critical

const MAX_PAYLOAD_SIZE = 10 * 1024 * 1024; // 10MB limit
const contentLength = parseInt(this.request.headers.get('content-length') || '0', 10);
if (contentLength > MAX_PAYLOAD_SIZE) {
  throw new Error('Payload too large');
}
const buffers = [];
let totalSize = 0;
for await (const chunk of this.request.body) {
  totalSize += chunk.length;
  if (totalSize > MAX_PAYLOAD_SIZE) {
    throw new Error('Payload too large');
  }
  buffers.push(chunk);
}
const content_raw = Buffer.concat(buffers).toString('utf8');

The code buffers the entire request body into memory without size limits, which can lead to memory exhaustion for large payloads.

This issue appears in multiple locations:

  • apps/meteor/app/integrations/server/api/api.js: Lines 91-95
  • apps/meteor/app/integrations/server/api/api.js: Lines 328-328
    Please implement size limits for request body processing to prevent memory exhaustion.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

@MarcosSpessatto MarcosSpessatto force-pushed the regression/incoming-integrations-hono branch from f7769aa to 376f7a5 Compare April 15, 2025 13:14
@MarcosSpessatto MarcosSpessatto marked this pull request as ready for review April 15, 2025 13:15
@MarcosSpessatto MarcosSpessatto requested a review from a team as a code owner April 15, 2025 13:15
@ggazzo ggazzo added this to the 7.6.0 milestone Apr 15, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Apr 15, 2025
@dionisio-bot dionisio-bot bot added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider and removed stat: QA assured Means it has been tested and approved by a company insider labels Apr 15, 2025
@ggazzo ggazzo merged commit d165f0c into develop Apr 15, 2025
50 checks passed
@dionisio-bot dionisio-bot bot removed stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Apr 15, 2025
@ggazzo ggazzo deleted the regression/incoming-integrations-hono branch April 15, 2025 14:58
@dionisio-bot dionisio-bot bot added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Apr 15, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants