From 47d0814dec3f4aa578dfc55d7d7b75f78b3653e8 Mon Sep 17 00:00:00 2001 From: Bryan Morgan Date: Thu, 19 Feb 2026 19:50:11 -0500 Subject: [PATCH] fix(ci): add fallback JSON extraction to issue triage workflow The Gemini CLI outputs debug lines (telemetry init, YOLO mode) to stdout that get captured alongside the model response. The parsing logic handled this when the model wrapped JSON in a markdown code block, but began failing when the model stopped doing so around Feb 18. Add a third fallback that extracts a raw JSON object from the mixed output. --- .../workflows/gemini-automated-issue-triage.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gemini-automated-issue-triage.yml b/.github/workflows/gemini-automated-issue-triage.yml index 08b97db0a2a..64609b5c3b3 100644 --- a/.github/workflows/gemini-automated-issue-triage.yml +++ b/.github/workflows/gemini-automated-issue-triage.yml @@ -284,8 +284,21 @@ jobs: return; } } else { - core.setFailed(`Output is not valid JSON and does not contain a JSON markdown block.\nRaw output: ${rawOutput}`); - return; + // If no markdown block, try to find a raw JSON object in the output. + // The CLI may include debug/log lines (e.g. telemetry init, YOLO mode) + // before the actual JSON response. + const jsonObjectMatch = rawOutput.match(/(\{[\s\S]*"labels_to_set"[\s\S]*\})/); + if (jsonObjectMatch) { + try { + parsedLabels = JSON.parse(jsonObjectMatch[0]); + } catch (extractError) { + core.setFailed(`Found JSON-like content but failed to parse: ${extractError.message}\nRaw output: ${rawOutput}`); + return; + } + } else { + core.setFailed(`Output is not valid JSON and does not contain extractable JSON.\nRaw output: ${rawOutput}`); + return; + } } }