Fix diagnostics on empty lines being invisible to get_errors tool#4025
Merged
roblourens merged 4 commits intomainfrom Mar 2, 2026
Merged
Fix diagnostics on empty lines being invisible to get_errors tool#4025roblourens merged 4 commits intomainfrom
roblourens merged 4 commits intomainfrom
Conversation
…cDescription When a diagnostic is reported on an empty/blank line (e.g., a trailing empty line at EOF), the DiagnosticDescription component was returning an empty JSX fragment because the code content was empty after trimEnd(). This caused the entire diagnostic (including its error message) to be invisible to the AI model. Fixed by removing the empty-line guard and always emitting the diagnostic message, just without a code block when the line has no content. Also adds a test case for diagnostics reported on empty lines. Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix get_errors tool and explain action ignoring diagnostics on empty lines
Fix diagnostics on empty lines being invisible to get_errors tool
Feb 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an issue in the Copilot Chat extension’s diagnostics prompting/tooling where diagnostics reported on blank lines were being omitted from rendered diagnostic text (impacting get_errors output and related prompt generation).
Changes:
- Updated
DiagnosticDescription.render()to always emit the diagnostic message, even when the extracted line content is empty/blank. - Added a
GetErrorsTooltest case that creates a diagnostic on a trailing empty line and snapshots the tool output. - Updated snapshots to reflect the new (now-visible) empty-line diagnostic output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/extension/prompts/node/inline/diagnosticsContext.tsx | Ensures diagnostic messages render even when the associated source line is empty/blank. |
| src/extension/tools/node/test/getErrorsTool.spec.tsx | Adds a regression test covering diagnostics reported on an empty line. |
| src/extension/tools/node/test/snapshots/getErrorsTool.spec.tsx.snap | Updates snapshots to include the newly reported empty-line diagnostic. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
bpasero
approved these changes
Mar 2, 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.
Diagnostics reported on empty/blank lines (e.g., a trailing newline at EOF where a compiler reports a missing
}) were silently dropped from theget_errorstool output andDiagnosticDescriptionprompts.Root cause:
DiagnosticDescription.render()extracted the line content and trimmed whitespace. For empty lines, this produced"", causing theif (code)guard to return an empty JSX fragment — swallowing the diagnostic message entirely. The model saw an<errors>tag with no content.Changes
diagnosticsContext.tsx— RefactoredDiagnosticDescription.render()to always emit the diagnostic message. When the line has content, renders the existingThis code at line N / <CodeBlock> / has the problem reportedformat; when empty, rendersAt line N / has the problem reportedwithout a code block:getErrorsTool.spec.tsx— Added test with a file containing a diagnostic on a trailing empty line, verifying it appears in tool output.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.