Skip to content

Conversation

@ggazzo
Copy link
Member

@ggazzo ggazzo commented Sep 29, 2025

https://rocketchat.atlassian.net/browse/FDR-179

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features
    • Added warning logs for request validation failures (query, body, and response), including method, path, and error details, to aid troubleshooting. No changes to existing behavior or responses.
  • Chores
    • Introduced a new logging dependency to support enhanced diagnostics within the HTTP router.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Sep 29, 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 Sep 29, 2025

⚠️ No Changeset found

Latest commit: fc8bc32

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
Contributor

coderabbitai bot commented Sep 29, 2025

Walkthrough

Adds @rocket.chat/logger as a dependency and introduces warning logs in HttpRouter for query, body, and response validation failures without changing control flow or responses.

Changes

Cohort / File(s) Summary
Dependency update
packages/http-router/package.json
Adds dependency @rocket.chat/logger.
Router validation logging
packages/http-router/src/Router.ts
Imports Logger, instantiates module-scope logger, and adds warning logs on query, body, and response validation failures. No changes to exported APIs or control flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant R as HttpRouter
  participant V as Validator
  participant L as Logger
  participant S as Service/Handler

  C->>R: HTTP request (method, path, query, body)
  R->>V: Validate query
  alt Query invalid
    V-->>R: Error(s)
    R->>L: warn(method, path, errors)
    R-->>C: 400/422 with error details
  else Query valid
    R->>V: Validate body
    alt Body invalid
      V-->>R: Error(s)
      R->>L: warn(method, path, errors)
      R-->>C: 400/422 with error details
    else Body valid
      R->>S: Invoke handler
      S-->>R: Response payload
      R->>V: Validate response
      alt Response invalid
        V-->>R: Error(s)
        R->>L: warn(method, path, errors)
        R-->>C: Error response
      else Response valid
        R-->>C: Success response
      end
    end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through routes where queries stray,
With twitching ears I log the way—
When bodies bungle, I gently warn,
And catch bad replies ere they’re born.
Carrots count, and so do errs;
Now every squeak the router hears. 🐇🪵📜

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues Check ✅ Passed The pull request adds a new @rocket.chat/logger dependency and emits warning logs on query, body, and response validation failures within Router.ts, which directly implements the objective of FDR-179 to improve router logs for validation errors.
Out of Scope Changes Check ✅ Passed All modifications in package.json and Router.ts relate exclusively to adding the logger dependency and inserting warning logs in validation error paths, with no unrelated or extraneous changes present.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title accurately reflects the primary change of the pull request by indicating that a logger is being added to the http-router for handling invalid operations, which directly corresponds to the newly imported logger instance and added warning logs on validation failures without introducing unrelated details or generic phrasing.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/logger-router

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 67.37%. Comparing base (5e821ad) to head (fc8bc32).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #37097   +/-   ##
========================================
  Coverage    67.37%   67.37%           
========================================
  Files         3330     3330           
  Lines       113482   113490    +8     
  Branches     20598    20599    +1     
========================================
+ Hits         76454    76469   +15     
+ Misses       34418    34409    -9     
- Partials      2610     2612    +2     
Flag Coverage Δ
e2e 57.31% <ø> (-0.01%) ⬇️
unit 71.15% <88.88%> (+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.

@ggazzo ggazzo marked this pull request as ready for review September 30, 2025 14:22
@ggazzo ggazzo added this to the 7.11.0 milestone Sep 30, 2025
@ggazzo ggazzo requested a review from sampaiodiego September 30, 2025 14:30
@ggazzo ggazzo changed the title feat(http-router): add logger for invalid operations chore(http-router): add logger for invalid operations Sep 30, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Oct 2, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Oct 2, 2025
@ggazzo ggazzo merged commit 40a45d8 into develop Oct 2, 2025
53 checks passed
@ggazzo ggazzo deleted the chore/logger-router branch October 2, 2025 02:04
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