Skip to content

Commit 9024f6a

Browse files
fix: handle invalid response structure from Gemini API in PR description generator (#112)
1 parent 66195ba commit 9024f6a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/actions/auto-pr-description/generate_pr_description.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ A short description of the changes.
7676
process.exit(1);
7777
}
7878

79+
if (!json.candidates[0].content.parts || !json.candidates[0].content.parts[0] || !json.candidates[0].content.parts[0].text) {
80+
console.error('Error: Invalid response structure from Gemini API - missing parts or text');
81+
console.error(JSON.stringify(json, null, 2));
82+
process.exit(1);
83+
}
84+
7985
const result = json.candidates[0].content.parts[0].text;
8086
process.stdout.write(result);
8187
} catch (error) {

0 commit comments

Comments
 (0)