fix: handle extra text in gemini output for dedup workflow (#6771)

This commit is contained in:
Gaurav 2025-08-21 13:40:44 -07:00 committed by GitHub
parent 720eb81890
commit 299bf58309
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -185,8 +185,13 @@ jobs:
core.info(`Raw duplicates JSON: ${rawJson}`);
let parsedJson;
try {
const trimmedJson = rawJson.replace(/^```(?:json)?\s*/, '').replace(/\s*```$/, '').trim();
parsedJson = JSON.parse(trimmedJson);
const jsonStringMatch = rawJson.match(/{[\s\S]*}/);
if (!jsonStringMatch) {
core.setFailed(`Could not find JSON object in the output.\nRaw output: ${rawJson}`);
return;
}
const jsonString = jsonStringMatch[0];
parsedJson = JSON.parse(jsonString);
core.info(`Parsed duplicates JSON: ${JSON.stringify(parsedJson)}`);
} catch (err) {
core.setFailed(`Failed to parse duplicates JSON from Gemini output: ${err.message}\nRaw output: ${rawJson}`);