Skip to content

Extract JSON from Copilot CLI response despite narration, fail visibly when missing - #598

Merged
dblock merged 1 commit into
masterfrom
dblock/fix-update-api-copilot-narration
Aug 25, 2026
Merged

Extract JSON from Copilot CLI response despite narration, fail visibly when missing#598
dblock merged 1 commit into
masterfrom
dblock/fix-update-api-copilot-narration

Conversation

@dblock

@dblock dblock commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

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

  • Extract the last line that looks like a JSON object (^\{.*\}$) from the response file, rather than trying to parse the whole file. Copilot CLI puts its final answer as the last line.
  • If no such line is found at all, fail the step visibly with ::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.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock
dblock force-pushed the dblock/fix-update-api-copilot-narration branch from 75bc305 to 63624c6 Compare August 25, 2026 02:35
…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
dblock force-pushed the dblock/fix-update-api-copilot-narration branch from 63624c6 to 0baddb1 Compare August 25, 2026 02:35
@dblock
dblock merged commit b9c2822 into master Aug 25, 2026
19 checks passed
@dblock
dblock deleted the dblock/fix-update-api-copilot-narration branch August 25, 2026 02:35
@coveralls

coveralls commented Aug 25, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 32801988660

Coverage remained the same at 90.971%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 5859
Covered Lines: 5330
Line Coverage: 90.97%
Coverage Strength: 99.99 hits per line

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants