Skip to content

Conversation

kmruiz
Copy link
Collaborator

@kmruiz kmruiz commented Sep 4, 2025

Proposed changes

Bug: MongoDB URLs passed as environment variables that contain multiple hosts are treated as arrays instead of actual URLS.
Fix: When the environment variable contents start with a mongodb connection protocol (mongodb://, mongodb+srv://) it skips preprocessing the contents and stores it in the config as is.

Fixes:

Checklist

@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 06:52
@kmruiz kmruiz requested a review from a team as a code owner September 4, 2025 06:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where MongoDB connection strings with multiple hosts were incorrectly parsed as arrays instead of being treated as valid URL strings. The fix adds special handling for MongoDB URLs in the environment variable parsing logic.

  • Added MongoDB protocol detection to skip preprocessing of connection strings
  • Added test coverage for multiple-host MongoDB URLs

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/common/config.ts Added MongoDB URL detection to prevent preprocessing of connection strings starting with mongodb:// or mongodb+srv://
tests/unit/common/config.test.ts Added test case to verify multiple-host MongoDB URLs are preserved correctly

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Environment variables are always strings, but we will add this check
in case we receive something that is not process.env.
CLI parsing doesn't have that issue but, in case we refactor
add a test to ensure we don't regress here.
Copy link
Collaborator

@himanshusinghs himanshusinghs left a comment

Choose a reason for hiding this comment

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

Looks perfect 💯

Copy link
Collaborator

@blva blva left a comment

Choose a reason for hiding this comment

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

non-blocking comment

@kmruiz kmruiz merged commit b26cd46 into main Sep 4, 2025
17 checks passed
@kmruiz kmruiz deleted the gh-327 branch September 4, 2025 10:43
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 17461171989

Details

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • 6 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 81.164%

Files with Coverage Reduction New Missed Lines %
src/common/session.ts 6 76.35%
Totals Coverage Status
Change from base Build 17461049947: -0.06%
Covered Lines: 4660
Relevant Lines: 5654

💛 - Coveralls

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