Skip to content

Conversation

@ricardogarim
Copy link
Contributor

@ricardogarim ricardogarim commented Nov 21, 2025

As per FB-72, when using MongoDB replica-set URLs (multiple hosts), the federation-matrix setup attempts to extract the database name by instantiating a URL object. Even though these MongoDB URLs are valid, the URL constructor does not support this format and throws ERR_INVALID_URL, preventing federation from starting.

This PR removes the manual URL parsing and dbName handling. We now read the database name directly from the MongoDB connection string using the MongoDB client parser. If the connection string does not contain a database name, we explicitly throw a clear error.

Summary by CodeRabbit

  • Refactor
    • Simplified database configuration parameters by removing the explicit database name field; database selection is now managed internally.
    • Updated MongoDB connection to use the MONGO_URL environment variable instead of MONGODB_URI.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Warning

Rate limit exceeded

@ricardogarim has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 24b173a and 14508a0.

📒 Files selected for processing (3)
  • packages/federation-sdk/src/index.ts (0 hunks)
  • packages/federation-sdk/src/services/database-connection.service.ts (2 hunks)
  • packages/homeserver/src/homeserver.module.ts (1 hunks)

Walkthrough

The name field was removed from the dbConfig object across the federation SDK and homeserver module. The database name is now sourced from MongoDB client options instead of configuration, and the MongoDB URI environment variable was changed from MONGODB_URI to MONGO_URL.

Changes

Cohort / File(s) Summary
Database Configuration Type Simplification
packages/federation-sdk/src/index.ts, packages/federation-sdk/src/services/database-connection.service.ts
Removed name: string field from dbConfig type signature in the init function and DatabaseConnectionService constructor. Database name now sourced from this.client.options.dbName instead of explicit config parameter.
Homeserver Module Database Config
packages/homeserver/src/homeserver.module.ts
Removed `name: process.env.DATABASE_NAME

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Areas requiring attention:
    • Verify MongoDB driver correctly provides dbName in client.options for all supported configurations
    • Confirm environment variable rename (MONGODB_URIMONGO_URL) is propagated across deployment configurations
    • Validate that removing explicit database name handling doesn't break existing multi-host MongoDB connection strings

Suggested reviewers

  • sampaiodiego

Poem

🐰 The rabbit hops past tangled names,
No parsing URLs in flames,
MongoDB's client knows the way,
Replicas sing in chorus today!
Config grows lean, the service runs true,

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ 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 accurately summarizes the main change: removing manual URL parsing for database names and relying on MongoDB client parser instead.
Linked Issues check ✅ Passed The PR directly addresses FB-72 by eliminating URL constructor calls that fail on replica-set connection strings, replacing them with MongoDB client database name parsing.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving the FB-72 issue: removing dbConfig.name parameter and switching to MongoDB client-based database name retrieval.

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-commenter
Copy link

codecov-commenter commented Nov 21, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.84%. Comparing base (9b5d392) to head (14508a0).

Files with missing lines Patch % Lines
...on-sdk/src/services/database-connection.service.ts 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #303      +/-   ##
==========================================
+ Coverage   52.82%   52.84%   +0.01%     
==========================================
  Files          96       96              
  Lines       12552    12556       +4     
==========================================
+ Hits         6631     6635       +4     
  Misses       5921     5921              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

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: 2

📜 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 9b5d392 and 24b173a.

📒 Files selected for processing (3)
  • packages/federation-sdk/src/index.ts (0 hunks)
  • packages/federation-sdk/src/services/database-connection.service.ts (2 hunks)
  • packages/homeserver/src/homeserver.module.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/federation-sdk/src/index.ts

@sampaiodiego sampaiodiego merged commit 80d84d3 into main Nov 26, 2025
3 checks passed
@sampaiodiego sampaiodiego deleted the chore/mongodb-dbname branch November 26, 2025 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants