fix: handle extra text in gemini output for dedup workflow (#6771)
This commit is contained in:
parent
720eb81890
commit
299bf58309
|
@ -185,8 +185,13 @@ jobs:
|
||||||
core.info(`Raw duplicates JSON: ${rawJson}`);
|
core.info(`Raw duplicates JSON: ${rawJson}`);
|
||||||
let parsedJson;
|
let parsedJson;
|
||||||
try {
|
try {
|
||||||
const trimmedJson = rawJson.replace(/^```(?:json)?\s*/, '').replace(/\s*```$/, '').trim();
|
const jsonStringMatch = rawJson.match(/{[\s\S]*}/);
|
||||||
parsedJson = JSON.parse(trimmedJson);
|
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)}`);
|
core.info(`Parsed duplicates JSON: ${JSON.stringify(parsedJson)}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.setFailed(`Failed to parse duplicates JSON from Gemini output: ${err.message}\nRaw output: ${rawJson}`);
|
core.setFailed(`Failed to parse duplicates JSON from Gemini output: ${err.message}\nRaw output: ${rawJson}`);
|
||||||
|
|
Loading…
Reference in New Issue