Repository navigation
fix(server): run cli.test.ts main() cases from an empty temp dir - #561
Merged
Merged
Conversation
main() calls loadDwkEnv() against process.cwd(), so a developer's local .env leaked into process.env during cli.test.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CMCuDa11Qr39yxAQJNUXoH
davidwkeith
commented
Oct 23, 2026
davidwkeith
left a comment
Owner
Author
There was a problem hiding this comment.
Review against CONTRIBUTING.md and the diff: no blocking issues.
Conforms
- The title is Conventional Commits (
fix(server): …) with a lowercase subject. - The body keeps the template headings
Summary,Packages affectedandChecklist. The inapplicable items are left unchecked, each with a one-line reason. - No changeset is needed, since
@dwk/serveris private. No catalog or conformance update is needed. - The code change is correct.
beforeEachandafterEachscope thechdirto themainblock. The two.envcases restore into the per-test temp dir, andafterEachthen restores the original cwd.workdir()is already defined at line 16. - The
packages/server/CLAUDE.mdupdate matches the new behaviour.
Suggestions
- The "Ran the local CI gate" item is unchecked because the full
pnpm lint && format:check && typecheck && build && testsequence wasn't run. CONTRIBUTING expects the whole gate before merge. Please run it, or confirm CI is green, and tick the box. - The
afterEachrestore of the cwd is correct. Ifworkdir()orprocess.chdirthrows inbeforeEach,prevCwdis still set first, so that case is safe too. No change is needed there.
Generated by Claude Code
Owner
Author
|
Ran the full local gate ( Generated by Claude Code |
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.
Summary
main()callsloadDwkEnv()againstprocess.cwd(), so a developer's local.envleaked intoprocess.envduringcli.test.ts(recorded in #560). Themaindescribe block nowchdirs into a fresh empty temp dir inbeforeEachand restores the cwd inafterEach. The two.envcases alreadychdirinto their own dirs and restore to that temp dir, so they're unchanged.Reproduced first: with
DWK_LEAK_PROBE=leakedin a repo-root.envand a probe inafterAll, the unfixed file read backPROBE=leaked. With this change it readsPROBE=undefined.packages/server/CLAUDE.md's test-secrets bullet now describes the fix instead of the leak.Packages affected
@dwk/server (test + docs only)
Checklist
spec/packages/and updated them ifbehaviour changed — not applicable, no behaviour change
src/*.test.ts)pnpm lint && pnpm format:check && pnpm typecheck && pnpm build && pnpm test— all five passed (257 test files, 3265 tests)pnpm changeset) if this touches a publishablepackage — not applicable,
@dwk/serveris privatecatalog.json/conformance/status.jsonif this adds a newmountable worker or changes conformance status — not applicable, no new worker
🤖 Generated with Claude Code
https://claude.ai/code/session_01CMCuDa11Qr39yxAQJNUXoH