fix(python): always use fake token in E2E tests to prevent hang#457
fix(python): always use fake token in E2E tests to prevent hang#457brettcannon wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes local Python E2E test hangs by ensuring the Copilot CLI never attempts interactive/credential-based auth when the harness points XDG_CONFIG_HOME at an empty temp directory.
Changes:
- Always pass
github_token="fake-token-for-e2e-tests"when constructing the shared Python E2ECopilotClient. - Update the one test that creates its own
CopilotClientto also always pass the fake token.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/e2e/testharness/context.py | Makes the shared E2E client always use a fake auth token to prevent CLI auto-login behavior from hanging tests locally. |
| python/e2e/test_session.py | Ensures the test-created “new client” uses the same fake token behavior as the harness client. |
The E2E test harness overrides XDG_CONFIG_HOME to an isolated temp directory. When running locally (not CI), github_token was None, so the CLI defaulted to use_logged_in_user=True but found no credentials in the empty temp dir. This caused a silent auth failure — the CLI logged 'Session was not created with authentication info' but never emitted a session.error event, making send_and_wait() hang forever. Since E2E tests use a replaying proxy with canned responses, real auth is never needed. Always pass the fake token.
9a137cc to
e0f50fd
Compare
|
After talking it over with @SteveSandersonMS , I'm going to close this PR. The official guidance is to get auth working in your environment in some fashion as outlined in https://github.com/github/copilot-sdk?tab=readme-ov-file#what-authentication-methods-are-supported, including the One piece of advice, though, is if you export the environment variable in your shell, either use your shell's ability to call commands inline or preface the environment export with a space to keep your token out of your shell history. |
Problem
When running Python E2E tests locally (outside CI), they hang indefinitely on any test that sends a message via
send_and_wait().Root Cause
The E2E test harness overrides
XDG_CONFIG_HOMEto an isolated temp directory for test isolation. When not in CI,github_tokenwasNone, so the CLI defaulted touse_logged_in_user=True— but found no credentials in the empty temp dir.The CLI logged
Error: Session was not created with authentication info or custom providerbut never emitted asession.errorevent back to the SDK, sosend_and_wait()blocked forever waiting for asession.idlethat would never come.Fix
Always pass
github_token="fake-token-for-e2e-tests"in the test harness and in the one test that creates its own client. Since E2E tests use a replaying proxy with canned responses, real auth is never needed.Verification
All 74 Python E2E tests pass (2 pre-existing skips for known unrelated issues).