Skip to content

fix(billing): billing.extraBalance.listLedger.perf.integration.tests.js fails on MongoDB < 5.2 () #3630

@PierreBrisorgueil

Description

@PierreBrisorgueil

Problem

billing.extraBalance.listLedger.perf.integration.tests.js fails locally on MongoDB 5.0.x:

MongoServerError: Invalid $project :: caused by :: Unrecognized expression '$sortArray'

$sortArray was added in MongoDB 5.2. The test + repository code (billing.extraBalance.repository.js line ~370) use $sortArray in an aggregation pipeline, which is unavailable in MongoDB 5.0.x.

Observed: MongoDB 5.0.7 local dev env (macOS, homebrew), 3 tests fail.
Passes: CI (ARC runner uses mongo:7, supports $sortArray).

Affected file(s)

  • modules/billing/repositories/billing.extraBalance.repository.js (line ~370)
  • modules/billing/tests/billing.extraBalance.listLedger.perf.integration.tests.js

Steps to reproduce

  1. Install MongoDB 5.0.x locally (brew install mongodb-community@5.0)
  2. Run NODE_ENV=trawl npm run test:integration -- --testPathPatterns=billing.extraBalance.listLedger
  3. Observe MongoServerError: Unrecognized expression '$sortArray'

Suggested fix

Options:

  1. Document MongoDB >= 5.2 as minimum required version in README + STRIPE_SETUP.md
  2. Add a skip guard in the test: if (mongoVersion < '5.2') test.skip(...)
  3. Use a sort-then-slice alternative ($unwind + $sort + $group) for compatibility

CI will pass regardless (mongo:7). This is a local DX issue discovered during /update-stack from trawl_node.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixA bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions