Skip to content

Commit 6804c52

Browse files
committed
fix(12-04): add try-catch to JSON.parse in IssueTriagingService
- Wrap JSON.parse in try-catch block - Provide descriptive error message on parse failure - Improves error handling for malformed AI triage responses
1 parent 4fa5251 commit 6804c52

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/services/IssueTriagingService.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,17 @@ export class IssueTriagingService {
5959

6060
const jsonMatch = response.text.match(/\{[\s\S]*\}/);
6161
if (!jsonMatch) {
62-
throw new Error('Failed to parse AI response');
62+
throw new Error('Failed to extract JSON from AI triage response');
63+
}
64+
65+
let triage;
66+
try {
67+
triage = JSON.parse(jsonMatch[0]);
68+
} catch (parseError) {
69+
const message = parseError instanceof Error ? parseError.message : String(parseError);
70+
throw new Error(`Failed to parse triage JSON: ${message}`);
6371
}
6472

65-
const triage = JSON.parse(jsonMatch[0]);
6673
return {
6774
issueId: params.issueId,
6875
issueTitle: params.issueTitle,

0 commit comments

Comments
 (0)