fix: enhance error handling in filterFalsePositivesWithAI to check for empty array response

This commit is contained in:
2026-05-12 03:22:50 +00:00
parent 878d8a5bb4
commit 2c59ce1bc1
+2 -2
View File
@@ -149,11 +149,11 @@ export async function filterFalsePositivesWithAI(findings) {
try {
const result = await chatJSON(systemPrompt, userContent);
if (Array.isArray(result)) {
if (Array.isArray(result) && result.length > 0) {
console.log(` AI 誤報過濾: ${findings.length} -> ${result.length}`);
return result;
}
throw new Error('AI 回傳非陣列');
throw new Error('AI 回傳空陣列或非陣列');
} catch (e) {
const status = e.response?.status;
if (status === 402 || status === 429) {