Support or ban imports from jstests in src/mongo/shell

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: Testing Infrastructure
    • None
    • DevProd Test Infrastructure
    • Fully Compatible
    • DevProd Test Infra 2026-06-16
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When .js files in src/mongo/shell import stuff from jstests, it can work in mongodb/mongo repo for resmoke.py tests, but it will fail when legacy mongo shell is run for performance tests in mongodb/mongo-perf because "mongo" shell is sent there as a standalone binary.

      We should either support this (somehow) or by banning this via linting

      To reproduce a simple example:

      diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
      index a557388e69a..05525f3e8b5 100644
      --- a/src/mongo/shell/assert.js
      +++ b/src/mongo/shell/assert.js
      @@ -1,4 +1,6 @@
       import {stringdiff, colorize} from "src/mongo/shell/stringdiff.js";
      +import {FeatureFlagUtil} from "jstests/libs/feature_flag_util.js"; 

      Will cause the shell to crash on startup outside of the repository

      $ (cd /tmp && /home/ubuntu/mongo/bazel-bin/install-mongo/bin/mongo --nodb)
      ...
      {"t":{"$date":"2026-06-03T17:01:18.751Z"},"s":"I",  "c":"QUERY",    "id":8972602, "ctx":"main","msg":"Setting up MozJS engine."}
      uncaught exception: Error: Cannot find module 'jstests/libs/feature_flag_util.js' imported from src/mongo/shell/assert.js (searched 1 path) :
      @:0:1
      exception: Error: Cannot find module 'jstests/libs/feature_flag_util.js' imported from src/mongo/shell/assert.js (searched 1 path) :
      @:0:1 

            Assignee:
            Sean Lyons
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: