标明缺失 Direct 传输正文
避免无 detail 载荷伪装成通道完整原因 补充旧载荷正文缺失回归测试
This commit is contained in:
+15
-5
@@ -103,6 +103,16 @@ function withVisibleFailureDetail(
|
||||
return safeDetail ? `${message}:${safeDetail}` : message;
|
||||
}
|
||||
|
||||
function withVisibleFailureDetailOrMissing(
|
||||
message: string,
|
||||
detail: string | null | undefined,
|
||||
) {
|
||||
const safeDetail = visibleDirectFailureDetail(detail);
|
||||
return safeDetail
|
||||
? `${message}:${safeDetail}`
|
||||
: `${message}:宿主未提供具体错误正文`;
|
||||
}
|
||||
|
||||
function stripUpstreamPrefix(
|
||||
detail: string | null | undefined,
|
||||
statusCode: number,
|
||||
@@ -188,17 +198,17 @@ function directModelCallText(
|
||||
detail,
|
||||
);
|
||||
case 'connectionFailed':
|
||||
return withVisibleFailureDetail(
|
||||
return withVisibleFailureDetailOrMissing(
|
||||
'执行通道连接失败,本轮未完成;请重试,若持续失败请检查项目诊断',
|
||||
detail,
|
||||
);
|
||||
case 'transportBroken':
|
||||
return withVisibleFailureDetail(
|
||||
return withVisibleFailureDetailOrMissing(
|
||||
'执行通道中断,本轮未完成;请重试,若持续失败请检查项目诊断',
|
||||
detail,
|
||||
);
|
||||
case 'streamUnavailable':
|
||||
return withVisibleFailureDetail(
|
||||
return withVisibleFailureDetailOrMissing(
|
||||
'流式响应协议不可用,本轮未完成;请检查项目诊断后重试',
|
||||
detail,
|
||||
);
|
||||
@@ -225,12 +235,12 @@ function directModelCallText(
|
||||
detail,
|
||||
);
|
||||
case 'emptyResponse':
|
||||
return withVisibleFailureDetail(
|
||||
return withVisibleFailureDetailOrMissing(
|
||||
'模型未返回内容,请重试;如持续失败请检查项目诊断',
|
||||
detail,
|
||||
);
|
||||
case 'payloadInvalid':
|
||||
return withVisibleFailureDetail(
|
||||
return withVisibleFailureDetailOrMissing(
|
||||
'模型回执无法解析,请重试;如持续失败请检查项目诊断',
|
||||
detail,
|
||||
);
|
||||
|
||||
@@ -76,6 +76,15 @@ describe('DirectProject 上游失败文案', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('旧载荷缺少传输正文时明确标记正文缺失,不伪装成完整原因', () => {
|
||||
const text = directTurnFailureNoticeText({
|
||||
type: 'modelCallFailed',
|
||||
kind: { type: 'transportBroken' },
|
||||
detail: '',
|
||||
});
|
||||
expect(text).toContain('宿主未提供具体错误正文');
|
||||
});
|
||||
|
||||
it('保留内存不足和 IPC 错误文本', () => {
|
||||
const text = directTurnFailureNoticeText({
|
||||
type: 'transportClosed',
|
||||
|
||||
Reference in New Issue
Block a user