Fix fetch_webpage crash on shell scripts due to undefined query embedding#4019
Draft
Fix fetch_webpage crash on shell scripts due to undefined query embedding#4019
Conversation
…lChunkEmbeddingsIndex Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix fetch_webpage crashing in VS Code
Fix fetch_webpage crash on shell scripts due to undefined query embedding
Feb 26, 2026
Member
|
@copilot Did you confirm that before this fix, the tests failed? I'd expect you to be able to repeat the failure, apply the fix, get the passing tests |
Contributor
Author
Yes, confirmed. With the original code (before fix), 4 of 6 tests fail with the exact crash from the issue: After applying the fix, all 6 tests pass. I just re-verified by reverting |
Co-authored-by: TylerLeonhardt <2644648+TylerLeonhardt@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fetch_webpagecrashes VS Code's extension host when fetching.shfiles (but not.html) because the chunking endpoint returns non-empty chunks for shell scripts. When noqueryis provided,computeEmbeddings('')returns{ values: [] }, makingqueryEmbedding = undefined.computeChunkScoresthen callsdistance(chunk.embedding, undefined)which throws aTypeErrorthat becomes an unhandled rejection, crashing the process.Changes
urlChunkEmbeddingsIndex.ts— primary fix:queryis empty/whitespace; return chunks unscoredcomputeEmbeddingsreturningundefined(when API returns empty values array)computeEmbeddingsreturn type fromPromise<Embedding>→Promise<Embedding | undefined>toChunksWithoutScores()helper to remove duplicationurlChunkEmbeddingsIndex.spec.ts— new unit tests covering empty query, undefined embedding, and the.shregression scenarioOriginal prompt
fetch_webpagecrashes VS code vscode#296098💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.