fix(python): always use fake token in E2E tests to prevent hang#457
Open
brettcannon wants to merge 1 commit intogithub:mainfrom
Open
fix(python): always use fake token in E2E tests to prevent hang#457brettcannon wants to merge 1 commit intogithub:mainfrom
brettcannon wants to merge 1 commit intogithub:mainfrom
Conversation
Contributor
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).