Skip to content

fix(webui): Apply direct MongoDB replica connection as in #1518 to resolve dev-env startup issue.#1598

Merged
davemarco merged 3 commits into
y-scope:mainfrom
davemarco:mongo2
Nov 19, 2025
Merged

fix(webui): Apply direct MongoDB replica connection as in #1518 to resolve dev-env startup issue.#1598
davemarco merged 3 commits into
y-scope:mainfrom
davemarco:mongo2

Conversation

@davemarco

@davemarco davemarco commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Description

Moving to docker compose introduced a bug that prevented connection to mongo database when running dev (no bug when actually running package). #1518 provided a fix, but not for webui. Adding fix for webui.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Can connect with dev launch command

Summary by CodeRabbit

  • Chores
    • Updated MongoDB connection configuration settings to ensure reliable database connectivity.

@coderabbitai

coderabbitai Bot commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A MongoDB connection URL parameter is appended to the autoConfig method to include directConnection=true. This modifies the connection string returned during configuration without changing function signatures or core control flow logic.

Changes

Cohort / File(s) Summary
MongoDB Connection Configuration
components/webui/server/src/plugins/external/mongo.ts
Appends directConnection=true parameter to the MongoDB connection URL string in the autoConfig implementation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file modification with a straightforward parameter addition
  • No logic changes or function signature alterations
  • No structural or control flow modifications

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: applying a direct MongoDB replica connection fix to the webui, referencing the related issue #1518 and the specific problem being resolved.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2c09c2d and a338f8c.

📒 Files selected for processing (1)
  • components/webui/server/src/plugins/external/mongo.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}

⚙️ CodeRabbit configuration file

  • Prefer false == <expression> rather than !<expression>.

Files:

  • components/webui/server/src/plugins/external/mongo.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: haiqi96
Repo: y-scope/clp PR: 0
File: :0-0
Timestamp: 2025-07-29T14:04:13.769Z
Learning: User haiqi96 requested creating a GitHub issue to document a bug fix from PR #1136, which addressed MySQL compatibility issues with invalid SQL CAST operations in the WebUI component.
🔇 Additional comments (1)
components/webui/server/src/plugins/external/mongo.ts (1)

9-9: Correction: Review comment is accurate; code change is verified and correctly applied.

The addition of ?directConnection=true is correct for test or development environments. Verification confirms this is the only MongoDB connection point in the codebase (no other instances require this fix), ensuring complete and consistent application of the fix across the TypeScript/JavaScript files.

The change is appropriate given that directConnection=true is recommended in test or development environments, and the PR description indicates this fix addresses a dev-environment-specific issue.

Note: In a production environment, MongoDB recommends configuring the cluster to make each MongoDB instance accessible outside of the Docker virtual network. Verify that your production deployment settings do not use this parameter or are configured appropriately for your MongoDB topology (replica sets should use proper member discovery without directConnection=true unless specifically intended).


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.

@davemarco davemarco marked this pull request as ready for review November 17, 2025 16:10
@davemarco davemarco requested a review from a team as a code owner November 17, 2025 16:10
@davemarco davemarco requested a review from hoophalab November 17, 2025 16:10
return {
forceClose: true,
url: `mongodb://${settings.MongoDbHost}:${settings.MongoDbPort}/${settings.MongoDbName}`,
url: `mongodb://${settings.MongoDbHost}:${settings.MongoDbPort}/${settings.MongoDbName}?directConnection=true`,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we know if it affects oplog tailing (e.g., Collection.watch())?

if we can't easily gain confidence that there's no effect, would it be better if we enable it only in the development environment? we can expose a settings.MongoDbDirectConnection with default value as false. then we can set it as true in controller.py

alternatively, we can follow the suggestions at https://www.mongodb.com/docs/manual/reference/connection-string-options/#mongodb-urioption-urioption.directConnection about "configuring the cluster to make each MongoDB instance accessible outside of the Docker virtual network", although i haven't investigated what's needed for our Docker Compose setup. (maybe simply adding another hostname when calling rs.initReplicaSet:

"members": [{"_id": 0, "host": netloc}],
)

@davemarco davemarco Nov 17, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do we know if it affects oplog tailing (e.g., Collection.watch())?

Not sure but i guess in dev, it still works
Also this is the same fix you already made in #1518? Maybe we make an issue to expose mongo? Or another PR to expose mongo and revert #1518?

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

deferring to @hoophalab 's review

@davemarco davemarco merged commit 0f18e59 into y-scope:main Nov 19, 2025
19 checks passed
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
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.

3 participants