VS Code finds problems in GitHub Copilot Chat code blocks. Why?
Asked Answered
E

3

9

When using GitHub Copilot Chat within Visual Studio Code, I've encountered an issue where TypeScript attempts to type check "temporary files" generated by Copilot. These files, identifiable by their hash-based filenames (e.g., c4507d29-b816-4a1c-9f29-c06addfc1204), are not part of my repository. Yet, TypeScript checks produce a plethora of errors, disrupting my workflow. The error messages suggest TypeScript treats these temporary outputs as part of my project, even though they're out of context and irrelevant to my actual codebase.

enter image description here

My questions are twofold: am I overlooking a straightforward setting or configuration related to GitHub Copilot and TypeScript, or has anyone else encountered this issue, and if so, how was it resolved?

I have tried excluding these files in my tsconfig.json, however I feel like this should not even be happening in the first place. I would expect TypeScript to ignore any generated code unless it is in one of the actual files of the project I am currently working on.

Ethelyn answered 6/3, 2024 at 15:13 Comment(1)
if you don't mind, could you try gradually rolling back to further older versions of the copilot chat extension and see if there's a specific version where this started happening? you can find instructions on rolling back hereOlga
O
7

This was a bug. It's supposed to be fixed in the latest VS Code Insiders. The fix should be in 1.88.0 when that releases (you can try that in VS Code Insiders). See issue ticket Problems in chat codeblocks show as workspace problems #206644.

In the meantime, you can edit your search.exclude setting (if that doesn't work, try files.exclude) to exclude files matching the following pattern (based on the pattern given by TonyH in their answer post, but I think this will be more accurate): [a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9]-[a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9][a-z0-9] (yes, it's verbose. I don't know if it works since I don't use GitHub Copilot, but if the idea works, then it's accurate and is less prone to exclude other things you might care about).

There's a related bug with chat stuff being included in references: Functions in Cached Chat files are being discovered as a reference in Visual Studio Code #1055. That issue is fixed by Pull Request Don't include internal schemes in references/implementation results #211149, which will be released in the May 2024 release of VS Code.

Olga answered 7/3, 2024 at 7:18 Comment(8)
I just tried **/*-*-*-*-* which seems to work as well, as a "search exclude" glob pattern.Permanganate
@Permanganate your pattern excludes all files with 4 - characters, the file pattern from the issue only filenames with hex characters and the correct amount of characters between -'s, there are very few false positives that match this pattern that are not UUID file namesDielle
@Dielle I agree. This was a quick fix. One that I will remove with VSCode 1.88.Permanganate
I still have this with 1.87.2 and none of the recommended search.excludes worked for me (sometimes it's clean on restart, but new "Problems" start showing up early in the session.Misha
@Misha raise a bug ticket ("Help > Raise Issue" in VS Code's menu), describing clearly what you observe and how to minimally reproduce it. then comment here with a link to your issue ticket so I can follow it.Olga
@Olga It's not fixed in 1.87.2. I know, you said full fix in 1.88. But what exactly does a "partial fix" represent?Orthman
@MikeS. that part of my answer is wrong. I misinterpreted a PR and its timeline. I've edit my answer now.Olga
Nonetheless, adding the proposed pattern to search (or file).exclude did not work for me. Testing with first search, then files, then both resulted in the same outcome: false error message. Guess I'll have to wait for 1.88. Appreciate the effort, though.Orthman
A
1

My fix for this is simple:

Most checkers (ShellCheck was my issue) have a way to exclude files.

The Copilot temporary or virtual files all seem to have hex names like e481a39b-6037-4f11-8dd4-9d813bf1de08

Excluding this glob: [a-f0-9]* will unmatch, and all the errors will be gone!

That said, personally this failed to fix my issue with Pylance, but did work with the ShellCheck extension. Perhaps they are peculiarities with the glob library each uses.

Alleviator answered 14/3, 2024 at 15:15 Comment(3)
FYI: Adding that search element didn't work for me. Oh well.Orthman
Sorry Mike S - I've had the same issue where PyLance didn't accept my glob, but Shellcheck did. I'm unsure why one worked, and the other did not.Alleviator
The good new is that v1.88 resolved the issue for me.Orthman
S
0

Use the following filter in the problems panel

!**/*-*-*-*-*
Species answered 14/8, 2024 at 17:9 Comment(1)
interesting. are you still getting this issue? what VS Code version are you on? What version of the GH Copilot / GH Copilot Chat extension are you on?Olga

© 2022 - 2025 — McMap. All rights reserved.