[codex] Add workspace path expectation guardrails#1058
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughConsolidates workspace path normalization into a new test helper module and updates tests to use it; adds guard tests that detect direct path assertions bypassing canonical-path helpers. Changes are test-only; no public API changes. ChangesWorkspace path helpers, test refactors, and guard tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/commands/workspace-path-guard.test.ts`:
- Around line 12-21: The existing negative regex checks in
workspace-path-guard.test.ts are too specific (they only look for .toEqual and
simple expressions) and can miss other forbidden assertions; update the
expect(source).not.toMatch(...) patterns (the ones referencing
".folders).toEqual(", "expect(workspaceFolders).toEqual(", the "Launch.args"
assertion, the "fs.realpathSync.native(...Launch.cwd" assertion, and the
"getWorkspaceCodeWorkspacePath(expectedExistingPath(" check) to match all common
Jest matchers and nested/complex expressions (e.g. toEqual, toStrictEqual, toBe,
toMatchObject, etc., and allow arbitrary whitespace and nested
parens/expressions) so any direct assertions against workspace folder paths or
Launch args/cwd are caught rather than only simple toEqual forms.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 003cc0b3-e4eb-40e3-bcd2-de4fef3266c5
📒 Files selected for processing (5)
test/commands/workspace-path-guard.test.tstest/commands/workspace.interactive.test.tstest/commands/workspace.test.tstest/core/workspace/foundation.test.tstest/helpers/workspace-paths.ts
alfred-openspec
left a comment
There was a problem hiding this comment.
Reviewed the diff and ran the focused workspace test slice locally: pnpm vitest run test/commands/workspace.test.ts test/commands/workspace.interactive.test.ts test/core/workspace/foundation.test.ts test/commands/workspace-path-guard.test.ts. The shared canonical-path helpers are a clean fix for the Windows runner short-path issue, and the guardrail test should prevent the same assertion pattern from creeping back in.
Summary
Adds a durable guardrail for the Windows path canonicalization failures that repeatedly broke the
mainWindows CI matrix.Why
Workspace commands intentionally canonicalize existing paths before storing, reporting, and passing them to openers. On GitHub Windows runners, raw temp paths can use short aliases such as
C:\Users\RUNNER~1\..., while Node's native realpath expands them toC:\Users\runneradmin\....The recent failures happened because tests kept comparing raw
mkdtemp/os.tmpdir()strings against values that had already gone through workspace canonicalization. Fixing individual assertions worked one at a time, but did not prevent the next similar test from reintroducing the same Windows-only failure.Changes
test/helpers/workspace-paths.tswith canonical workspace path expectation helpers:expectedExistingPathexpectedWorkspaceCodeWorkspacePathexpectedWorkspaceFoldersexpectWorkspaceLaunchLogtest/commands/workspace-path-guard.test.ts, which fails ifworkspace.test.tsreintroduces direct generated workspace-folder array comparisons, direct opener launch-arg comparisons, or one-offgetWorkspaceCodeWorkspacePath(expectedExistingPath(...))assertions.Validation
pnpm vitest run test/commands/workspace.test.ts test/commands/workspace.interactive.test.ts test/core/workspace/foundation.test.ts test/commands/workspace-path-guard.test.tspnpm testpnpm run buildpnpm exec tsc --noEmitpnpm lintSummary by CodeRabbit