Extract JSON from Copilot CLI response despite narration, fail visibly when missing - #598
Merged
Merged
Conversation
Danger ReportNo issues found. |
dblock
force-pushed
the
dblock/fix-update-api-copilot-narration
branch
from
August 25, 2026 02:35
75bc305 to
63624c6
Compare
…y when missing Copilot CLI's response file can include narration/thinking lines before its final JSON answer (observed in run 32801440182), so the previous fix (#596) silently discarded a perfectly good AI-generated changelog because the whole file wasn't valid JSON. Instead, extract the last line that looks like a JSON object and parse just that. If no JSON object is found at all, fail the workflow visibly with ::error:: instead of silently falling back to the generic changelog entry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dblock
force-pushed
the
dblock/fix-update-api-copilot-narration
branch
from
August 25, 2026 02:35
63624c6 to
0baddb1
Compare
Coverage Report for CI Build 32801988660Coverage remained the same at 90.971%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Problem
PR #596 fixed the workflow crashing on non-JSON AI responses, but as a side effect it also silently discarded valid AI-generated changelog entries whenever Copilot CLI's response included narration/thinking text before its final JSON answer.
This is exactly what happened in run 32801440182: the workflow succeeded, but fell back to the generic "Update API from slack-api-ref@..." entry even though the AI had produced a correct, detailed
{"entries": [...]}JSON object — it was just preceded by several lines of Copilot CLI narration ("Let me inspect the actual diffs...", etc).Fix
^\{.*\}$) from the response file, rather than trying to parse the whole file. Copilot CLI puts its final answer as the last line.::error::instead of silently falling back to the generic entry, so a genuinely broken AI response is caught rather than masked.Verified against the actual response text captured from the failing run, good/invalid synthetic responses, and confirmed correct entries are now extracted in all cases.