Skip to content

Malformed absolute paths in read_file and list_dir trigger "Allow reading external files?" prompt, then fail on GitHub Copilot #293204

Closed as duplicate

Description

Summary

When GitHub Copilot's read_file or list_dir tools receive an absolute path missing the drive colon — either Git Bash style (/c/path/to/file) or leading-backslash style (\c\path\to\file) instead of the correct Windows form (C:\path\to\file) — VS Code presents a user-facing "Allow reading external files?" or "Allow reading external directory?" security dialog. The file is inside the workspace. If the user allows the operation, it fails anyway because the path resolves incorrectly. The two tools also resolve the same malformed input via different internal code paths, producing different error messages.

This is the third of three related bugs in Copilot's search tools affecting multi-root workspaces on Windows. The principal issue is tracked in #293428.

Environment

  • OS: Windows 11, integrated terminal using Git Bash
  • VS Code: 1.109
  • Workspace: Any (single-root or multi-root)

Reproduction

Setup

Any workspace containing a readable file, e.g.:

C:\projects\alpha\
    src/
        hello.txt

Steps

  1. Use read_file with filePath: "C:\projects\alpha\src\hello.txt" — correct form, as baseline.
  2. Use read_file with filePath: "/c/projects/alpha/src/hello.txt" — Git Bash style.
  3. Use read_file with filePath: "\c\projects\alpha\src\hello.txt" — leading backslash, no drive colon.
  4. Use list_dir with path: "/c/projects/alpha/src".
  5. Use list_dir with path: "\c\projects\alpha\src".

Expected

Steps 2–5 should either resolve the path correctly to the workspace file, or fail immediately with a clear error indicating the path format is invalid. No user-facing security prompt should appear for files within the workspace.

Actual

  • Step 1 (C:\...): ✅ Works.
  • Step 2 (/c/..., read_file): ❌ User sees "Allow reading external files?" dialog. The chat shows the mangled path \c\projects\alpha\src\hello.txt. After allowing: "Unable to resolve nonexistent file \c\projects\alpha\src\hello.txt". The file genuinely exists — only the path resolution is wrong.
  • Step 3 (\c\..., read_file): ❌ Same dialog, same mangled display, same failure after approval.
  • Step 4 (/c/..., list_dir): ❌ User sees "Allow reading external directory?" dialog. After allowing: "ENOENT: no such file or directory, scandir C:\c\projects\alpha\src" — the current drive C:\ was prepended, producing a doubled path.
  • Step 5 (\c\..., list_dir): ❌ Same dialog as Step 4. Same C:\c\projects\... resolution, same ENOENT.

Problems

1. Security prompt for workspace-internal files

Both malformed path formats cause VS Code to classify the target as "external" and present a security prompt, even though the target is inside the workspace. This interrupts the user for a request that will fail regardless.

2. Failure after user approval

Approving the security dialog does not help — the path still cannot be resolved. The prompt misleadingly implies the operation might succeed if allowed. Testing confirmed this with files that genuinely exist on disk at the correct C:\... path: the operation fails after approval, not because the file is missing, but because the internal path resolution never produces the correct drive-letter path.

3. Path display is mangled

When the chat UI displays the operation (e.g., "Reading hello.txt"), the path shown is \c\projects\alpha\src\hello.txt — backslashes without a drive colon. This is not a valid Windows path and is not the path the LLM requested (which may have been the Git Bash form /c/...).

4. Inconsistent internal resolution between tools

The two tools resolve the same malformed input differently:

Malformed Input read_file Resolution list_dir Resolution
/c/projects/alpha/src/hello.txt file:///c/projects/... → fails C:\c\projects\... → ENOENT
\c\projects\alpha\src\hello.txt file:///c/projects/... → fails C:\c\projects\... → ENOENT

read_file converts to a file:/// URI lacking the drive letter (Windows requires file:///C:/...). list_dir prepends the current working drive, producing a doubled path. Both fail, but via different code paths with different error messages.

How Malformed Paths Arise

LLMs produce these paths in a predictable scenario:

  1. The user's integrated terminal is Git Bash, which displays paths as /c/projects/....
  2. The LLM observes terminal output (e.g., from pwd or find) using this format.
  3. The LLM adopts the format for subsequent read_file or list_dir calls, not realizing these tools require Windows-native paths.

This is not an exotic edge case. Git Bash is the default Git shell on Windows and a common choice for VS Code's integrated terminal. The inline tools must handle Git Bash style paths on Windows.

Recommendation

  1. Detect and normalize. When a path matches the pattern /x/... or \x\... on Windows (where x is a single letter), the tool layer should recognize this as a drive-letter path and normalize it to X:\... before resolution.
  2. Suppress the external-file prompt when the normalized path resolves to a location within the workspace.
  3. Unify path resolution between read_file and list_dir so that the same input produces the same internal resolution and error behavior.
  4. Display the path correctly in the chat UI, preserving the format the LLM used or normalizing to the correct Windows form — not a hybrid with backslashes but no drive colon.

Related Issues

Activity

  1. added
    chat-ext-issue
    on Feb 5, 2026
  2. removed
    chat-ext-issue
    on Feb 5, 2026
  3. garretwilson commented on Feb 5, 2026

    @garretwilson
    Author

    This is a more severe manifestation of previous bugs such as #284697. But in this case the LLM was not at fault. I would bet that some new checks in v1.109 are naive and "they work fine on my Mac, so ship it"! 🙁

  4. changed the title [-]Severe usability bug on Windows: Git Bash paths are flagged as out of the workspace[/-] [+]Git Bash paths are flagged as out of the workspace on Windows[/+] on Feb 5, 2026
  5. garretwilson commented on Feb 5, 2026

    @garretwilson
    Author

    I've removed "severe" from the title as I haven't seen this again. (This would be severe if it were to happy regularly.) It may only happen when the file does not exist. Or it may have something to do with using an underpowered model (in this case Claude Haiku 4.5). I'll update when I have more information.

  6. changed the title [-]Git Bash paths are flagged as out of the workspace on Windows[/-] [+]Malformed absolute paths in `read_file` and `list_dir` trigger "Allow reading external files?" prompt, then fail on GitHub Copilot[/+] on Feb 6, 2026
  7. garretwilson commented on Feb 6, 2026

    @garretwilson
    Author

    roblourens, it turns out this is a significant issue after all. It is part of three crucial failures in GitHub Copilot VS Code workspace search tools. I have updated the ticket description accordingly. I'll include the text matrix below.

    I have put in a lot of comprehensive investigative work on behalf of the GitHub Copilot Team. I would appreciate your attention to the related tickets #293428 (crucial), #293430, and #293204 (this one). Thank you.

  8. garretwilson commented on Feb 6, 2026

    @garretwilson
    Author

    VS Code Search Tool Path Resolution — Comprehensive Test Matrix

    Legend

    • ✅ = works correctly
    • ❌ = silent failure (no results or nonexistent file error)
    • 🔶 = triggers spurious "external file/directory" security prompt, then fails
    • ⚠️ = partial results (fewer matches than expected)
    • — = not applicable (tool doesn't accept this format)

    Bug Key

    Path Formats Tested

    # Format Example
    1 Root-relative, / src/main/App.java
    2 Root-relative, \ src\main\App.java
    3 Root-relative, mixed src\main/App.java
    4 Recursive glob, / **/App.java
    5 Recursive glob, \ **\App.java
    6 Root-prefixed, explicit, / alpha/src/main/App.java
    7 Root-prefixed, explicit, \ alpha\src\main\App.java
    8 Root-prefixed, /**/ glob alpha/**/App.java
    9 Root-prefixed, \**\ glob alpha\**\App.java
    10 Windows absolute, \ C:\projects\alpha\src\App.java
    11 Windows absolute, / C:/projects/alpha/src/App.java
    12 Git Bash absolute /c/projects/alpha/src/App.java
    13 Leading \, no colon \c\projects\alpha\src\App.java

    Results

    # Path Format file_search grep_search read_file list_dir
    1 root-relative / ✅ ✅ — —
    2 root-relative \ ✅ ✅ — —
    3 root-relative mixed ✅ ✅ — —
    4 **/file / ✅ ✅ — —
    5 **\file \ ✅ ✅ — —
    6 root-prefixed / ✅ ❌ A — —
    7 root-prefixed \ ✅ ❌ A — —
    8 root /**/ glob ✅ ❌ A — —
    9 root \**\ glob ⚠️ B ❌ A — —
    10 C:\ absolute — ❌ ✅ ✅
    11 C:/ absolute — ❌ ✅ ✅
    12 /c/ Git Bash — ❌ 🔶 C 🔶 C
    13 \c\ no colon — ❌ 🔶 C 🔶 C

    Reading the Table

    • Bug A (rows 6–9, grep_search column): root-name prefix silently rejected.
    • Bug B (row 9, file_search column): \**\ glob produces partial/no results.
    • Bug C (rows 12–13, read_file/list_dir columns): malformed absolute paths prompt then fail.
    • Rows 1–5: all tools agree — these are the safe patterns.
    • Rows 10–11: correct absolute paths work for read_file/list_dir; file_search and grep_search don't accept absolute paths (by design, not a bug).
  9. garretwilson commented on Feb 6, 2026

    @garretwilson
    Author

    Connor Peet (@connor4312) and roblourens , although I originally filed this ticket for a file that did not exist, further investigation shows that there are several scenarios that will cause this. In fact the updated description clearly says:

    Step 2 … The file genuinely exists — only the path resolution is wrong.

    You closed this ticket as a duplicate of #292424, which only covers non-existing files.

    I spent a long time doing comprehensive tests and providing a complete matrix with many scenarios. I would hate that you only address the "non-existent" scenario, ant that I would have to lose another entire morning filing more tickets (as I did this morning) after the next release.

    Does the new ticket truly cover all the scenarios described here?

    Does the GitHub Copilot team intend to put in place a comprehensive test suite to cover all these scenarios to make sure they are all addressed and to prevent regression?

  10. connor4312 commented on Feb 7, 2026

    @connor4312
    Member

    In your Step 2-5 cases, those should fail to resolve to a file on disk. So we should not present a warning dialog and just allow the tool to indicate failure to the model, just like we would for a valid path that doesn't exist. #292424 will cover this pretty well.

    I suggest opening up a dedicated issue for the "Tool Path Resolution" stuff. That is related to search APIs which are their own world, we do varying degrees of normalization there which are unique from the simpler read file / dir listing tools.

  11. garretwilson commented on Feb 7, 2026

    @garretwilson
    Author

    I suggest opening up a dedicated issue for the "Tool Path Resolution" stuff. That is related to search APIs which are their own world, we do varying degrees of normalization there which are unique from the simpler read file / dir listing tools.

    I'm not understanding. I put a lot of work into #293428, #293430, and #293204, which are significant lapses that severely impact LLM behavior and productivity. Are you saying they should be re-filed for a different team?

  12. garretwilson commented on Feb 7, 2026

    @garretwilson
    Author

    So we should not present a warning dialog and just allow the tool to indicate failure to the model …

    Connor Peet (@connor4312) one thing I'm not sure is being emphasized here is that the tools fail under different conditions! If you don't think a path should work and want the tool to fail because of that, that's one thing. But shouldn't the tools fail in the same way for the same input paths? That's what I'm getting at with these three tickets.

    The problem (and this is from real-world experience) is that the LLM is going to use some path format (for whatever reason), and it will work on one search tool, so it will use the same path format on another tool, and that other tool will provide really odd results, so the LLM will come up with all sorts of reasoning to try to make this inconsistency make sense (as would a human).

    Figuring out that the tools have bugs that make them behave differently for the same paths is the last thing the LLM is going to think of (if ever; I had to really push the tool for it to figure that out) so instead the LLM will assume something else and muck up the project because it thought the search tools worked the same way and one tool gave it bad information that it took as true (because the same approach worked with other tools).

    That's why I keep emphasizing: there needs to be a suite of tests for input paths across the search tools so that they will all work consistently. Really that's just standard practice and common sense.

  13. locked and limited conversation to collaborators on Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions