This commit is contained in:
Your Name
2026-08-27 14:23:23 +08:00
parent b5b14516a1
commit 2fa8492c56
27 changed files with 3832 additions and 1435 deletions
@@ -192,6 +192,40 @@ expectSame(false, callPrivate('shouldRetryWithoutFiles', [400, []]), 'a text-onl
expectSame(false, callPrivate('shouldRetryWithoutFiles', [401, $capped['kept']]), 'a credential failure is not retried');
expectSame(false, callPrivate('shouldRetryWithoutFiles', [500, $capped['kept']]), 'an upstream outage is not retried here');
// 协议回退会把最初的“附件被拒”换成另一协议的状态码(Dify 400 -> OpenAI 404),
// 降级判断必须按每次响应累计,否则去掉附件的重试永远不会发生。
expectSame(
true,
callPrivate('isFileRejection', [['errno' => 0, 'http_code' => 400], $capped['kept']]),
'an attachment rejection is recognised on the response that carried it'
);
expectSame(
false,
callPrivate('isFileRejection', [['errno' => 0, 'http_code' => 404], $capped['kept']]),
'the fallback protocol 404 is not itself an attachment rejection'
);
expectSame(
true,
callPrivate('isFileRejection', [
['errno' => 0, 'http_code' => 200, 'upstream_error' => true],
$capped['kept'],
]),
'a 200 stream carrying event:error counts as an attachment rejection'
);
expectSame(
false,
callPrivate('isFileRejection', [
['errno' => 0, 'http_code' => 200, 'upstream_error' => true],
[],
]),
'a text-only request never degrades further'
);
expectSame(
false,
callPrivate('isFileRejection', [['errno' => 28, 'http_code' => 0], $capped['kept']]),
'a transport failure is not mistaken for an attachment rejection'
);
// Dify 的 inputs 必须是 JSON 对象。PHP 空数组会被编码成 [],上游以
// invalid_param 拒绝整单——空 inputs 的调用方会 100% 失败。
$emptyInputs = callPrivate('buildRequestSpecs', [