Skip to content

Commit 99fa700

Browse files
authored
fix(ci): add fallback JSON extraction to issue triage workflow (#19593)
1 parent f1c0a69 commit 99fa700

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/gemini-automated-issue-triage.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,21 @@ jobs:
284284
return;
285285
}
286286
} else {
287-
core.setFailed(`Output is not valid JSON and does not contain a JSON markdown block.\nRaw output: ${rawOutput}`);
288-
return;
287+
// If no markdown block, try to find a raw JSON object in the output.
288+
// The CLI may include debug/log lines (e.g. telemetry init, YOLO mode)
289+
// before the actual JSON response.
290+
const jsonObjectMatch = rawOutput.match(/(\{[\s\S]*"labels_to_set"[\s\S]*\})/);
291+
if (jsonObjectMatch) {
292+
try {
293+
parsedLabels = JSON.parse(jsonObjectMatch[0]);
294+
} catch (extractError) {
295+
core.setFailed(`Found JSON-like content but failed to parse: ${extractError.message}\nRaw output: ${rawOutput}`);
296+
return;
297+
}
298+
} else {
299+
core.setFailed(`Output is not valid JSON and does not contain extractable JSON.\nRaw output: ${rawOutput}`);
300+
return;
301+
}
289302
}
290303
}
291304

0 commit comments

Comments
 (0)