Repository navigation
fix: report empty Copilot replies as empty instead of invalid JSON (#91) - #253
Merged
Sanjay Singh (san360) merged 1 commit intoNov 23, 2026
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
4 of 10 tasks
Sanjay Singh (san360)
force-pushed
the
san360-issue-91-error-llm-returned-invalid-json-after-3-666c20
branch
from
November 20, 2026 18:27
c7e9130 to
c27d574
Compare
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change to empty-response error reporting.
No open issues 🎉
What changed in this PR
Corrects misleading errors in JSON-based AI features such as Generate Quiz, Slop or Not, and Skill Finder. Empty Copilot replies now produce an empty-response message rather than an invalid-JSON error, addressing #91.
Changes:
- Detects whitespace-only replies before JSON parsing while preserving retry behavior.
- Extracts retry preparation into a helper.
- Adds a regression test and changelog entry.
| File | Description |
|---|---|
src/webview/panel-llm.ts |
Distinguishes empty replies from JSON parse failures and extracts retry preparation. |
src/webview/panel-llm-call.test.ts |
Verifies three empty replies produce the empty-response error. |
CHANGELOG.md |
Documents the corrected error reporting. |
Review effort: Balanced
callLlmJson passed an empty reply to the JSON parser, which threw a JSON error, so every retry counted as a parse failure and AI features such as Generate Quiz, Slop or Not and Skill Finder showed "LLM returned invalid JSON after 3 attempts". A whitespace-only reply is now detected before either parse path (structured output or the lenient parser) and, when no attempt returns non-JSON text, reported with the same "GitHub Copilot returned an empty response" message callLlm already uses. Genuine parse failures still report invalid JSON. Retries behave as before: structured output is dropped on every retry and the JSON hint is added. Fixes #91 Co-authored-by: Copilot App <[email protected]>
Sanjay Singh (san360)
force-pushed
the
san360-issue-91-error-llm-returned-invalid-json-after-3-666c20
branch
from
November 23, 2026 08:48
c27d574 to
2f9a916
Compare
Aymen (aymenfurter)
approved these changes
Nov 23, 2026
Aymen (aymenfurter)
approved these changes
Nov 23, 2026
Sanjay Singh (san360)
deleted the
san360-issue-91-error-llm-returned-invalid-json-after-3-666c20
branch
November 23, 2026 10:35
4 tasks done
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.
Description
AI features such as Generate Quiz, Slop or Not and Skill Finder could fail with "LLM returned invalid JSON after 3 attempts. Please try again." when GitHub Copilot returned an empty response (#91).
Root cause:
callLlmJsoninsrc/webview/panel-llm.tspassed an empty reply straight to the JSON parser.JSON.parsefailed, then the lenient parser threw "No JSON structure found in LLM response", which matched the parse-failure check, so each empty retry was counted as invalid JSON and the user saw a misleading message.Fix:
callLlmalready uses (the existingEMPTY_RESPONSE_MESSAGE): "GitHub Copilot returned an empty response. Try again."main: structured output is dropped on every retry (Fix: drop structured-output options unconditionally on retry #277) and the JSON hint is added for the next attempt, including after an empty reply. That logic moved into a smallprepareJsonRetryhelper to keepcallLlmJsonwithin the lint complexity limit.call-faileddebug log now classifies a whitespace-only reply asshape=empty.src/webview/panel-llm-call.test.ts:mainwith "LLM returned invalid JSON after 3 attempts", passes with this change);CHANGELOG.mdentry under Unreleased.Rebase: rebased on current
main. Model selection stays on Copilot Auto viaselectModel(#301) and the unconditional structured-output fallback from #277 is kept; this PR only adds the empty-reply handling. #272 also changes empty-response handling incallLlmJson, so whichever lands later will need a rebase.Related Issues
Fixes #91
Checklist
npm run checkpasses (typecheck + lint + spellcheck + knip + tests): each step run locally on the final head:npm run typecheck: passednpm run lint: passed (0 errors, no new warnings; no warnings in the changed files)npm run spellcheck(cspell"src/**/*.ts" "docs/**/*.md" "*.md"): passed (416 files, 0 issues)npm run knip: passednpm run lockfile-lint: passednpm test: passed (168 files, 3776 passed, 5 skipped)npm run build: passednpm run check-size: passed (dist/extension.js1.76 MB, within the 2 MB budget)CHANGELOG.md