Skip to content

fix: use container-internal env vars in mongo healthcheck#259

Merged
HardMax71 merged 1 commit intomainfrom
fix/deploy-creds
Mar 3, 2026
Merged

fix: use container-internal env vars in mongo healthcheck#259
HardMax71 merged 1 commit intomainfrom
fix/deploy-creds

Conversation

@HardMax71
Copy link
Copy Markdown
Owner

@HardMax71 HardMax71 commented Mar 3, 2026

Summary by cubic

Fix MongoDB healthcheck in docker-compose by using explicit host/port and container env vars for credentials. This avoids the “storedKey mismatch” on mongosh 2.6.0 + MongoDB 8 and prevents password mangling.

  • Bug Fixes
    • Use mongosh with --host/--port and db.adminCommand("ping") against admin instead of a URI with a database path.
    • Read creds from $$MONGO_INITDB_ROOT_USERNAME/$$MONGO_INITDB_ROOT_PASSWORD to defer expansion to the container and support special characters.

Written for commit d06cdce. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Enhanced database health monitoring for improved service reliability.

mongosh 2.6.0 + MongoDB 8.0 produces "storedKey mismatch" when the
connection URI includes a database path (localhost/integr8scode) while
--authenticationDatabase points to a different db (admin). Switching to
explicit --host/--port flags with --username/--password avoids this.

Also replaces ${MONGO_PASSWORD:-...} host-side interpolation (which
mangles passwords containing $, `, " via the container's sh) with
$$MONGO_INITDB_ROOT_USERNAME / $$MONGO_INITDB_ROOT_PASSWORD — the $$
escape tells docker-compose to emit a literal $ so the container shell
expands the variables from the mongo container's own environment, where
they are already set by the environment: block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 3, 2026 19:19
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 3, 2026

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 3, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Flag Coverage Δ
backend-e2e 83.22% <ø> (+0.01%) ⬆️
backend-unit 67.91% <ø> (ø)
frontend-unit 86.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend 90.07% <ø> (ø)
Frontend 86.86% <ø> (ø)
🚀 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d5f635c and d06cdce.

📒 Files selected for processing (1)
  • docker-compose.yaml

📝 Walkthrough

Walkthrough

The MongoDB healthcheck in docker-compose.yaml was updated to use an explicit mongosh invocation with host 127.0.0.1, port 27017, and root credentials derived from environment variables, evaluating db.adminCommand("ping") instead of piping a shell-based ping command.

Changes

Cohort / File(s) Summary
Configuration Update
docker-compose.yaml
Updated MongoDB healthcheck from shell-piped ping command to explicit mongosh invocation with programmatic authentication using environment-derived credentials.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A healthier check, from the shell to the code,
MongoDB now proves its status on the road,
With explicit credentials and pingable cheer,
The docker-compose whispers: "All systems are clear!" 🎉

🚥 Pre-merge checks | ✅ 3
✅ 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 primary change: updating the MongoDB healthcheck to use container-internal environment variables instead of inline credentials.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/deploy-creds

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Copy Markdown

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 the MongoDB healthcheck command in docker-compose.yaml to use container-internal environment variables ($$MONGO_INITDB_ROOT_USERNAME / $$MONGO_INITDB_ROOT_PASSWORD) instead of host-level shell variables (${MONGO_USER} / ${MONGO_PASSWORD}), ensuring the healthcheck works reliably regardless of the host environment.

Changes:

  • Replaces shell-interpolated host env vars with Docker-escaped ($$) container-internal env vars
  • Switches from echo ... | mongosh to mongosh --eval style invocation

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

@HardMax71 HardMax71 merged commit 833bcf9 into main Mar 3, 2026
18 of 20 checks passed
@HardMax71 HardMax71 deleted the fix/deploy-creds branch March 3, 2026 19:26
@coderabbitai coderabbitai Bot mentioned this pull request Mar 3, 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