Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

Fixes #261610

Technically the bug is already fixed as I am unable to repro with symlinks (code reading from such files is already protected).

This PR fixes one place which does not have the protection, although it is defence in depth as well since it works without this change.

Copilot AI review requested due to automatic review settings December 13, 2025 12:19
@dmitrivMS dmitrivMS added the chat-prompts Prompt and Instruction files related issues label Dec 13, 2025
@dmitrivMS dmitrivMS requested a review from aeschli December 13, 2025 12:19
@dmitrivMS dmitrivMS enabled auto-merge (squash) December 13, 2025 12:19
@dmitrivMS dmitrivMS self-assigned this Dec 13, 2025
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Dec 13, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a defense-in-depth fix for handling invalid files when searching for copilot-instructions.md files in workspace folders. While the original bug mentioned in issue #261610 is already protected elsewhere in the code, this change adds an additional safety layer by validating that discovered paths reference actual files rather than directories or symlinks.

Key changes:

  • Replaced fileService.exists() with fileService.stat() to enable file type validation
  • Added stat.isFile check to filter out non-file resources (directories, symlinks)
  • Added try-catch error handling to gracefully skip inaccessible or invalid paths
  • Added trace logging for debugging when files are skipped

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

Labels

chat-prompts Prompt and Instruction files related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Copilot] Edge case around broken symlinks

2 participants