StylistService.cs: Unsafe array access on OpenAI response Content[0]
- 主要语言
- 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 还没有评估数据。