Repository navigation
[local-isolate-worker-init-unit-tests-from-the] Isolate worker-init unit tests from the host GITHUB_TOKEN - #857
Merged
danii1 merged 1 commit intoDec 4, 2026
Conversation
…te worker-init unit tests from the host GITHUB_TOKEN
Contributor
Author
Artifacts & verificationRun: 1736 · Commit: Verification reportProduced by Show artifactAuto-review summaryProduced by Show artifact |
Contributor
Author
|
🛑 Auto-merge: left open for human review (checked
devintern checks again after new commits or a change to the auto-merge policy. |
danii1
deleted the
feature/local-isolate-worker-init-unit-tests-from-the
branch
December 4, 2026 16:51
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.
Why
Task local-isolate-worker-init-unit-tests-from-the: Isolate worker-init unit tests from the host GITHUB_TOKEN
worker-init.test.tsfailed wheneverGITHUB_TOKENwas set in the host environment, and the DevIntern worker exports it to every agent run.runWorkerInitcorrectly reuses an existing token and skips the token prompt. The test's scripted answers (ghp_test, then an empty line) then shifted by one, soghp_testwas consumed as the task query. The test was reading the real process environment, not an isolated one.What changed
In
packages/code/tests/setup/worker-env.ts, I added host GitHub credentials to the sharedWORKER_INJECTED_ENV_VARSlist:GITHUB_TOKEN,GH_TOKEN,GITHUB_APP_ID,GITHUB_APP_PRIVATE_KEY_BASE64andGITHUB_APP_PRIVATE_KEY_PATH. That list is already applied in two places:guard-worker-env.ts) strips it from in-process test code;run-tests.tsstrips it from the environment of spawned CLI children.This fixes the whole class of leaks at the isolation layer, so no test or product code changed.
Scope
Included: the test isolation list only. Excluded: onboarding behavior (reusing an existing
GITHUB_TOKENstays as is),runWorkerInit, and the individual worker-init tests. I did not check whether other tracker credentials, such as Jira or Linear tokens, leak into tests in the same way.Tradeoffs
The scrub is broad, so any test that relied on an ambient
GITHUB_TOKENwould now fail. None did: the full suite passes. The cost is that a test needing a token must set it itself. I chose this over pinning env in thedeps()helper because it also covers sibling tests and future ones.Blast Radius
This affects every
packages/codetest process and any CLI child the tests spawn. Production code is untouched. I did not grep the tests for ones that assert on these variables being absent.Verification
All run from
packages/codeunless noted.GITHUB_TOKEN=ghp_dummy bun run test tests/worker-init.test.ts: 107 pass, 0 fail.GITHUB_TOKEN=ghp_dummy GH_TOKEN=x bun run test(full suite): 6527 pass, 0 fail.env -u GITHUB_TOKEN bun run test(full suite): 6527 pass, 0 fail.bun run typecheckandbun run lintfrom the repo root: both exit 0.env -u GITHUB_TOKENcommand on its own, and the offline e2e tests. The unset case is covered by the full-suite run.🤖 Opened by DevIntern from local-isolate-worker-init-unit-tests-from-the