Skip to content

fix(tests): use junction symlinks for Windows compatibility#1750

Open
Hrishi75 wants to merge 1 commit into
ComposioHQ:mainfrom
Hrishi75:fix/windows-test-symlink-junction
Open

fix(tests): use junction symlinks for Windows compatibility#1750
Hrishi75 wants to merge 1 commit into
ComposioHQ:mainfrom
Hrishi75:fix/windows-test-symlink-junction

Conversation

@Hrishi75
Copy link
Copy Markdown

@Hrishi75 Hrishi75 commented May 9, 2026

Summary

  • Pass "junction" as the third argument to symlinkSync in two test files so they no longer fail with EPERM on Windows for users without admin privileges or Developer Mode
  • Matches the existing pattern in production code at packages/plugins/workspace-worktree/src/index.ts where junctions are already used as a Windows fallback

Why

On Windows, symlinkSync(target, path) defaults to a directory symlink, which requires SeCreateSymbolicLinkPrivilege — i.e. Administrator privileges or Developer Mode. For non-admin contributors without Developer Mode, this fails with EPERM: operation not permitted, symlink .... Junctions are functionally equivalent for directory targets in these tests and do not require elevation.

The Node.js docs confirm the type argument is ignored on non-Windows OSes, so Linux/macOS behavior is unchanged.

Files changed

  • packages/core/src/__tests__/project-resolver.test.ts:218 — test "matches a flat local config launched from a symlinked checkout"
  • packages/web/src/__tests__/projects-route.test.ts:227 — test "POST /api/projects > reconnects to the existing project ID when the same path is registered again"

Test plan

  • Reverted the change locally on Windows 11; both tests fail with EPERM at the symlinkSync call sites
  • Re-applied the change; both tests pass
  • pnpm --filter @aoagents/ao-core test — no regressions
  • pnpm --filter @aoagents/ao-web test — no regressions
  • pnpm typecheck clean
  • CI on ubuntu-latest (verifies POSIX behavior unchanged)
  • CI on windows-latest

Two test files create directory symlinks via raw `symlinkSync(target, path)`,
which fails with EPERM on Windows for users without admin privileges or
Developer Mode. Passing junction as the third argument switches Windows
to a junction (no elevation required); on POSIX the type argument is
ignored by Node, so behavior is unchanged on Linux/macOS.

Matches the existing pattern in
`packages/plugins/workspace-worktree/src/index.ts` where production code
already uses junction fallbacks on Windows for the same reason.

Verified locally on Windows 11 by stashing the change, confirming the
EPERM failure reproduces at both call sites, then re-applying and
confirming both tests pass.
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR fixes two test fixtures that create directory symlinks, passing "junction" as the third argument to symlinkSync so they succeed on Windows without requiring administrator privileges or Developer Mode. The "junction" type argument is ignored on macOS and Linux, so POSIX CI behavior is unchanged.

  • packages/core/src/__tests__/project-resolver.test.ts — adds "junction" to the symlinked-checkout fixture at line 218.
  • packages/web/src/__tests__/projects-route.test.ts — adds "junction" to the alias-directory fixture at line 227. Both changes match the existing fallback pattern already used in packages/plugins/workspace-worktree/src/index.ts.

Confidence Score: 5/5

Safe to merge — two minimal, targeted one-line fixes that bring test fixtures in line with the established production pattern.

Both changed lines are test-only fixtures that create directory symlinks. Passing "junction" is the correct, well-precedented approach for directory symlinks on Windows; Node.js documents that the argument is ignored on non-Windows platforms, so there is no risk to Linux/macOS CI runs. The fix matches existing production code in the same repo.

No files in the changeset require special attention. A follow-up could address the similar bare symlinkSync call on a directory at packages/plugins/agent-kimicode/src/index.test.ts:1005.

Important Files Changed

Filename Overview
packages/core/src/tests/project-resolver.test.ts Adds "junction" type to symlinkSync for the symlinked-checkout test fixture — correct fix for Windows EPERM; non-Windows ignores the argument.
packages/web/src/tests/projects-route.test.ts Adds "junction" type to symlinkSync for the alias-directory test fixture — same correct pattern as the core change, no behavioral difference on POSIX.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["symlinkSync(target, path, 'junction')"] --> B{Platform?}
    B -->|Windows| C["Creates NTFS junction\n(no admin required)"]
    B -->|macOS / Linux| D["Creates directory symlink\n('junction' argument ignored)"]
    C --> E["Test passes ✓"]
    D --> E
Loading

Comments Outside Diff (1)

  1. packages/plugins/agent-kimicode/src/index.test.ts, line 1005 (link)

    P2 Untreated directory symlink — this call creates a directory symlink (real is created with mkdirSync) and will still fail with EPERM on Windows without admin privileges or Developer Mode, the same root cause fixed in the two files changed by this PR. Passing "junction" here would bring it in line with the updated tests and the production pattern in workspace-worktree/src/index.ts. The same pattern appears at lines 1046, 1047, and 1319 in this file, though those targets are .jsonl files rather than directories and would need a different resolution (hardlink or explicit skip).

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/plugins/agent-kimicode/src/index.test.ts
    Line: 1005
    
    Comment:
    **Untreated directory symlink** — this call creates a directory symlink (`real` is created with `mkdirSync`) and will still fail with `EPERM` on Windows without admin privileges or Developer Mode, the same root cause fixed in the two files changed by this PR. Passing `"junction"` here would bring it in line with the updated tests and the production pattern in `workspace-worktree/src/index.ts`. The same pattern appears at lines 1046, 1047, and 1319 in this file, though those targets are `.jsonl` files rather than directories and would need a different resolution (hardlink or explicit skip).
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
packages/plugins/agent-kimicode/src/index.test.ts:1005
**Untreated directory symlink** — this call creates a directory symlink (`real` is created with `mkdirSync`) and will still fail with `EPERM` on Windows without admin privileges or Developer Mode, the same root cause fixed in the two files changed by this PR. Passing `"junction"` here would bring it in line with the updated tests and the production pattern in `workspace-worktree/src/index.ts`. The same pattern appears at lines 1046, 1047, and 1319 in this file, though those targets are `.jsonl` files rather than directories and would need a different resolution (hardlink or explicit skip).

Reviews (1): Last reviewed commit: "fix(tests): use junction symlinks for Wi..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant