Repository navigation
fix: keep paused debug location range valid in chat - #342379
Merged
Connor Peet (connor4312) merged 3 commits intoOct 19, 2026
Merged
Connor Peet (connor4312) merged 3 commits into
Connor Peet (connor4312) merged 3 commits into
Conversation
Debug adapters may report a line or column of 0 when it is unknown, as the Debug Adapter Protocol allows. "Add to Chat" on a variable, watch expression or scope attached the paused location with that range as-is. Converting it for chat participants produced a negative position and threw "Illegal argument: character must be non-negative", and because the attachment is replayed with the chat history, every later request in that session failed. Attach the whole line instead when the line or column is unknown, and add a unit test for the paused location range. Fixes microsoft#329777
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix preserves existing valid-range behavior and includes regression coverage; tests were not independently executed.
No open issues 🎉
What changed in this PR
Fixes #329777 by normalizing unknown debugger positions in chat attachments without changing the debug model.
Changes:
- Converts zero-valued starting positions into valid whole-line ranges.
- Adds regression coverage for valid positions, unknown columns, and unknown lines.
| File | Description |
|---|---|
src/vs/workbench/contrib/debug/test/browser/debugChatIntegration.test.ts |
Tests the three paused-location range cases. |
src/vs/workbench/contrib/debug/browser/debugChatIntegration.ts |
Normalizes unknown positions before attaching them to chat. |
Review effort: Balanced
Connor Peet (connor4312)
requested changes
Oct 19, 2026
When a debug adapter reports line 0 for the paused stack frame, attach the file without a range and tell the model that the debugger is paused somewhere in that file (in the named frame) and that the line is unknown, instead of attaching line 1. An unknown column with a known line still attaches the whole line.
Connor Peet (connor4312)
enabled auto-merge
October 19, 2026 18:09
Bhavya U (bhavyaus)
approved these changes
Oct 19, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 19, 2026
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.
Fixes #329777
A debug adapter may report
line/column0 for a stack frame when it doesn't know them, which the Debug Adapter Protocol allows (GDB-based adapters commonly do this). "Add to Chat" on a variable, watch expression or scope attaches the paused location throughcreatePausedLocationEntry, which passed that range through as-is. Converting it for chat participants (Range.to→new Position(line, -1)) throwsIllegal argument: character must be non-negative, and becauseprepareHistoryTurnsreplays the attachment with the history, every later request in the session fails.When the column is unknown, the paused location now covers the whole line, the same shape the existing empty-range branch produces. When the line is unknown, it attaches the file without a range and tells the model the debugger is paused somewhere in that file (in the named frame) and that the adapter didn't report the line, rather than pointing at line 1. The debug model keeps the adapter's values; only the chat attachment is normalized, so other stack frame consumers are unchanged.
Testing
debugChatIntegration.test.tscovers the three cases above. It fails before the fix and passes after; the CallStack, Hover, Source and Session debug suites still pass.column: 0for the top frame (for example mock-debug patched to returncolumn: 0), pause, right-click a variable → Add to Chat and send a prompt. Without this change, requests in that chat fail withIllegal argument: character must be non-negative(full trace in the issue).Sessions that already hit this keep the bad range in their saved history. Guarding the reference conversion in
prepareHistoryTurnswould cover those too; happy to follow up with that separately if you'd like.