Skip to content

[Python][tests] E2E harness picks the first @github/copilot-* package instead of the current platform package #2103

Description

@syedkazmi14

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

  1. Leave COPILOT_CLI_PATH unset.
  2. 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.
  3. Run any Python test that imports e2e.testharness.context or CLI_PATH.
  4. get_cli_path_for_tests() returns the first matching package instead of the package for the current platform.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions