From 9501231148039e64f9872b53aed340a30f076173 Mon Sep 17 00:00:00 2001 From: WangDL Date: Sat, 23 May 2026 09:38:47 +0800 Subject: [PATCH] fix: optional chaining on safetyCheck --- src/modules/ai/gateway/ai-gateway.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/ai/gateway/ai-gateway.service.ts b/src/modules/ai/gateway/ai-gateway.service.ts index 3b929ff..cb4f8bc 100644 --- a/src/modules/ai/gateway/ai-gateway.service.ts +++ b/src/modules/ai/gateway/ai-gateway.service.ts @@ -50,7 +50,7 @@ export class AiGatewayService { }); const safetyCheck = await this.contentSafety?.check(output.rawText, { contentType: 'ai_output' }).catch(() => ({ safe: true })); - if (!safetyCheck.safe) throw new Error('AI output blocked by content safety'); + if (!safetyCheck?.safe) throw new Error('AI output blocked by content safety'); const parsed = this.parseJson(output.rawText, request.outputSchema); const estimatedCost = this.costCalculator.calculate(