Skip to content

hooks: a dangling .zero junction can disable beforeTool blocking on Windows #1219

Open

Description

@EddieMurphy89

Version / branch / commit

main at 17fcd26602dc685fd1596739c4d718932d856d9e; found while reviewing #1211.

OS and environment

Windows 10/11, cmd.exe; junction created with mklink /J (no symlink privilege needed).

Steps to reproduce

  1. Create a workspace directory with a .zero junction pointing at a target directory.
  2. Put a valid hooks.json under the target.
  3. Remove the junction target, leaving .zero as a dangling junction.
  4. Load the project hook layer / run a beforeTool hook in that workspace.

Expected behavior

The hook config is known to exist but cannot be resolved, so LoadConfig returns ErrInvalidConfig and beforeTool stays blocked.

Actual behavior

On Windows, os.Lstat reports a junction as ModeIrregular rather than ModeSymlink. danglingSymlinkInPath only checked the symlink bit, so it skipped the dangling .zero junction. LoadConfig returned no error and no diagnostics, and beforeTool ran with no policy.

Relevant logs, screenshots, or error messages

Reproduced on Windows with mklink /J; Lstat returned mode ?rw-rw-rw- with no symlink bit, ReadFile returned not-exist, and LoadConfig returned no error. PR #1211 now checks Lstat existence plus Stat not-exist, which treats any dangling link/junction as invalid, and adds a Windows junction regression test.

Activity

  1. Vasanthdev2004 commented on Nov 20, 2026

    @Vasanthdev2004
    Collaborator

    Marking this bug and issue-approved. I reproduced the junction case myself while reviewing #1211: a dangling .zero junction made with mklink /J was skipped by the symlink-only check, and the Windows test in that PR fails when the fix is reduced to the symlink bit. #1211 is the fix and is approved from my side.

  2. added
    bug
    issue-approved
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissue-approved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions