AB-Law / AB-Law/Pluck-It

StylistService.cs: Unsafe array access on OpenAI response Content[0]

未关闭
#95 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug
主要语言
TypeScript
星标
0
派生
0
平均合并
16 分钟
30 天内合并 PR
1

描述

## Problem

`PluckIt.Infrastructure/StylistService.cs:68` directly accesses `result.Content[0].Text` without checking if `Content` is non-empty. If OpenAI returns an empty content array (on refusal or model error) this throws an unhandled `IndexOutOfRangeException`.

```csharp
var content = result.Content[0].Text; // throws if Content is empty
```

## Impact

Any stylist recommendation request that receives a non-standard OpenAI response crashes with a 500 and gives the user no actionable message.

## Proposed Fix

```csharp
if (result.Content is not { Count: > 0 })
throw new InvalidOperationException("OpenAI returned empty content.");
var content = result.Content[0].Text;
```

## Functionality Impact

Converts silent crash to explicit structured error response.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。