Skip to content

Redact MongoDB credentials in connection-string log line (closes #16)#29

Merged
sierra-moxon merged 3 commits into
mainfrom
issue-16-redact-mongo-uri-log
May 21, 2026
Merged

Redact MongoDB credentials in connection-string log line (closes #16)#29
sierra-moxon merged 3 commits into
mainfrom
issue-16-redact-mongo-uri-log

Conversation

@turbomam

Copy link
Copy Markdown
Member

Why

MongoDBLoader.__init__ logged f"MongoDB connection string: {self.handle}" at INFO level. self.handle is the full URI built by get_mongo_connection_string(), which embeds the username and password in the URL userinfo. So every loader run printed the password to:

  • the developer's terminal
  • terminal scrollback / tmux logs
  • Dagster job output in production
  • any CI log that captures the loader's stdout

Discovered while running the loader earlier this session.

What

Log host:port/db only. The full URI is still constructed and stored on self.handle for use by linkml_store; it just no longer appears in human-readable log output.

-            logger.info(f"MongoDB connection string: {self.handle}")
+            logger.info(
+                f"Connecting to mongodb://{self.db_config.db_host}:{self.db_config.db_port}"
+                f"/{self.db_config.db_name}"
+            )

Verification

make test still passes (11 passed, 8 skipped).

Closes #16.

`MongoDBLoader.__init__` previously logged the full self.handle URI at
INFO level, including the password embedded in the URL userinfo. This
leaked the password to terminals, CI logs, Dagster job output, and any
captured terminal scrollback.

Log just `host:port/db` instead. The full URI is still stored on
`self.handle` for use by linkml_store, but it no longer appears in
human-readable output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 20, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Prevents leaking MongoDB credentials by removing an INFO-level log line that printed the full MongoDB URI (including userinfo with username/password). This aligns with the loader’s operational needs (still constructing self.handle for linkml_store) while making runtime logs safe for terminals, CI, and Dagster output.

Changes:

  • Replaced INFO logging of the full MongoDB connection string with a host/port/db-only log message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

turbomam and others added 2 commits May 20, 2026 14:14
Back-propagates the formatting from integration commit 7a32f0c so this
branch matches what ruff format (post-PR #31) wants. Keeps the branch
consistent with main if PR #31 lands first.

Pure formatting; no behavior change.
@sierra-moxon sierra-moxon merged commit 0a2550c into main May 21, 2026
6 checks passed
@turbomam turbomam deleted the issue-16-redact-mongo-uri-log branch June 2, 2026 23:23
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.

Mongo connection string logged with embedded password at INFO level

3 participants