Skip to content

fix(billing): $sortArray in listLedgerPage requires MongoDB 5.2+ (fails on 5.0.x) #3774

@PierreBrisorgueil

Description

@PierreBrisorgueil

Problem

modules/billing/repositories/billing.extraBalance.repository.js uses \$sortArray in an aggregation pipeline, which requires MongoDB 5.2+. The integration test billing.extraBalance.listLedger.perf.integration.tests.js (added in devkit) fails on local environments running MongoDB 5.0.x:

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

Discovered during /update-stack on pierreb_node (local MongoDB 5.0.7).

Affected files

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

Steps to reproduce

  1. Run against MongoDB 5.0.x: NODE_ENV=pierreb npm run test:integration
  2. The listLedgerPage integration tests fail with Unrecognized expression '$sortArray'

Fix options

  • Either document MongoDB ≥5.2 as a minimum requirement in README
  • Or replace \$sortArray with a \$sort stage on the outer pipeline (compatible with 5.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixA bug fix

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions