Skip to content

Make bumpie-meds pregnancy safety modules optional dependencies - #123

Merged
Isaloum merged 4 commits into
mainfrom
copilot/fix-bumpie-meds-module-errors
Jan 26, 2026
Merged

Make bumpie-meds pregnancy safety modules optional dependencies#123
Isaloum merged 4 commits into
mainfrom
copilot/fix-bumpie-meds-module-errors

Conversation

Copilot AI commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Tests failing due to hard dependency on bumpie-meds/src/services/pregnancy-safety-engine and related modules. Package not present in repository or package.json, causing module resolution failures at require-time.

Changes

medication-tracker.js

  • Wrapped pregnancy module requires in try-catch, only suppressing MODULE_NOT_FOUND errors
  • Added null checks in checkPregnancySafety() before calling module methods
  • Returns structured error response when modules unavailable:
{
  safe: false,
  error: 'Pregnancy safety modules not available',
  recommendation: 'Unable to assess safety - consult healthcare provider immediately',
  warning: 'The bumpie-meds package is required for pregnancy safety checks'
}

docs/tests/critical-features.test.js

  • Fixed Storage.prototype reference (Node.js has no Storage constructor)
  • Added try-catch in ErrorHandler.handle() to prevent error-tracking failures from propagating
  • Proper mock lifecycle with beforeEach/afterEach

Result

Application degrades gracefully when optional modules missing. All 2117 tests pass.

Original prompt

Fix Missing bumpie-meds Module Causing Test Failures

Problem

The CI/CD pipeline is failing with the following error:

Error: Cannot find module 'bumpie-meds/src/services/pregnancy-safety-engine'

This error occurs in medication-tracker.js at lines 11-14 where it attempts to require pregnancy safety modules from the bumpie-meds package that doesn't exist in the repository or package.json.

Root Cause

The file medication-tracker.js (ref: 993107f) has hard dependencies on:

  • bumpie-meds/src/services/pregnancy-safety-engine
  • bumpie-meds/src/services/pregnancy-interaction-checker
  • bumpie-meds/src/services/pregnancy-risk-calculator
  • bumpie-meds/src/services/pregnancy-audit-logger

These modules are not installed or available, causing Node.js module resolution to fail during test execution.

Solution Required

Fix the issue by making the pregnancy safety modules optional with proper error handling:

  1. Update medication-tracker.js (lines 10-32):

    • Wrap the require statements in try-catch blocks
    • Provide fallback implementations or null values when modules are unavailable
    • Add console warnings when modules can't be loaded
    • Ensure all methods that use these modules check if they're available before calling them
  2. Update the checkPregnancySafety method (lines 733-784):

    • Add null checks before using pregnancy safety modules
    • Return appropriate error/warning messages when modules aren't available
    • Ensure the method degrades gracefully
  3. Key Requirements:

    • Tests must pass without the bumpie-meds dependency
    • No breaking changes to existing functionality
    • Clear warnings when optional features are unavailable
    • All existing tests should continue to work

Files to Modify

  • medication-tracker.js - Add optional dependency handling for bumpie-meds modules

Test Validation

After the fix:

  • All tests in the test suite should pass (currently 1 failed, 2116 passed)
  • The specific failing test: docs/__tests__/critical-features.test.js → "Error Handling › should handle database errors gracefully" should also be addressed
  • No new errors should be introduced

Reference

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 26, 2026 04:14
Co-authored-by: Isaloum <155708736+Isaloum@users.noreply.github.com>
Co-authored-by: Isaloum <155708736+Isaloum@users.noreply.github.com>
Co-authored-by: Isaloum <155708736+Isaloum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix missing bumpie-meds module causing test failures Make bumpie-meds pregnancy safety modules optional dependencies Jan 26, 2026
Copilot AI requested a review from Isaloum January 26, 2026 04:21
@Isaloum
Isaloum marked this pull request as ready for review January 26, 2026 04:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f73fecd306

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread medication-tracker.js
Comment on lines +23 to +27
// Only suppress MODULE_NOT_FOUND errors; re-throw other errors like syntax errors
if (error.code === 'MODULE_NOT_FOUND') {
console.warn('⚠️ Warning: bumpie-meds pregnancy safety modules not available.');
console.warn(' Pregnancy safety features will be disabled.');
console.warn(' To enable these features, install the bumpie-meds package.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-throw MODULE_NOT_FOUND from non-optional deps

Because the catch treats any MODULE_NOT_FOUND as “optional dependency missing,” a broken install of bumpie-meds (e.g., a missing transitive dependency or a renamed internal file) will be silently swallowed and pregnancy safety will be disabled without surfacing the real error. This makes production misconfigurations look like an expected optional state and can lead to missing safety checks even when the package is present. Consider only suppressing errors when the missing module is the bumpie-meds package itself (e.g., check error.message/require.resolve), and rethrow other MODULE_NOT_FOUND cases.

Useful? React with 👍 / 👎.

@Isaloum
Isaloum merged commit 90717a4 into main Jan 26, 2026
8 of 10 checks passed
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.

2 participants