Summary
The Python test harness resolves the Copilot CLI by scanning nodejs/node_modules/@github for copilot-* directories and returning the first index.js it finds:
for platform_pkg in sorted(github_modules.glob("copilot-*")):
candidate = platform_pkg / "index.js"
if candidate.exists():
return str(candidate.resolve())
That selection is based on directory order, not the current OS/arch. As a result, Python tests can choose the wrong platform package when multiple @github/copilot-* packages are present, or whenever the checked-out node_modules tree contains only a mismatched platform package.
This logic lives in python/e2e/testharness/context.py and also affects tests that import CLI_PATH from that harness, such as python/test_client.py.
Why this is a bug
The Node SDK already resolves platform packages explicitly in nodejs/src/client.ts via getCliPlatformPackageNames(), using the current platform/arch and handling Linux linux vs linuxmusl variants.
The repo also already fixed the same class of problem for the .NET E2E harness in #2093, where directory enumeration order was selecting the wrong platform-specific package.
Python still has the older directory-order-based logic.
Repro
- Leave
COPILOT_CLI_PATH unset.
- Have more than one
@github/copilot-* package under nodejs/node_modules/@github, or otherwise have a checked-out node_modules tree whose available copilot-* package(s) do not match the current host platform.
- Run any Python test that imports
e2e.testharness.context or CLI_PATH.
get_cli_path_for_tests() returns the first matching package instead of the package for the current platform.
- The Python test process then tries to launch the wrong CLI entrypoint.
Expected behavior
The Python harness should resolve the platform package the same way the runtime code already does elsewhere in the repo:
- choose
win32 / darwin / linux based on the current platform
- choose the correct architecture
- on Linux, distinguish
linux vs linuxmusl
Suggested fix
Mirror the platform-aware package selection used in nodejs/src/client.ts instead of scanning copilot-* in sorted order.
Related
Summary
The Python test harness resolves the Copilot CLI by scanning
nodejs/node_modules/@githubforcopilot-*directories and returning the firstindex.jsit finds:That selection is based on directory order, not the current OS/arch. As a result, Python tests can choose the wrong platform package when multiple
@github/copilot-*packages are present, or whenever the checked-outnode_modulestree contains only a mismatched platform package.This logic lives in
python/e2e/testharness/context.pyand also affects tests that importCLI_PATHfrom that harness, such aspython/test_client.py.Why this is a bug
The Node SDK already resolves platform packages explicitly in
nodejs/src/client.tsviagetCliPlatformPackageNames(), using the current platform/arch and handling Linuxlinuxvslinuxmuslvariants.The repo also already fixed the same class of problem for the .NET E2E harness in #2093, where directory enumeration order was selecting the wrong platform-specific package.
Python still has the older directory-order-based logic.
Repro
COPILOT_CLI_PATHunset.@github/copilot-*package undernodejs/node_modules/@github, or otherwise have a checked-outnode_modulestree whose availablecopilot-*package(s) do not match the current host platform.e2e.testharness.contextorCLI_PATH.get_cli_path_for_tests()returns the first matching package instead of the package for the current platform.Expected behavior
The Python harness should resolve the platform package the same way the runtime code already does elsewhere in the repo:
win32/darwin/linuxbased on the current platformlinuxvslinuxmuslSuggested fix
Mirror the platform-aware package selection used in
nodejs/src/client.tsinstead of scanningcopilot-*in sorted order.Related
@github/copilotpackage layout where the runnableindex.jslives in platform-specific packages