fix(approval-runs): 传输层失败不再被误判为业务结论
`sealApprovalRunFlowGet` 用两次"请求被拒"充当路由信号:记录查询被拒,就
认为入参是单号;运行记录列表被拒,就认为该单据没有 AI 记录。两处都写成
裸 `catch {}`,于是所有失败都被吸收进这两个业务结论。
后果不是偶尔不准,而是以十足的语气给出错误答案:token 过期、连接重置、
网关 5xx 会被渲染成「单据已删除」或「AI 从未审核」,用户没有任何线索去
怀疑刚才那次请求其实失败了;退出码同时失去语义,本该由 classifyCliError
产出 11(认证/上游失败),实际退化成一次"成功的查询"。
现在只有标识符形态的拒绝才计为未命中:HTTP 400/404/422,或响应体确实
到达但不是一条审批记录。认证失败、5xx、限流、以及根本没有响应的传输
错误一律原样上抛。
- errors:导出既有的 `responseStatus` 结构读取器,让调用方能区分"没有
响应"与"收到了 400/404 响应"。
- approval-runs:新增 `isUpstreamLookupMiss`,替换两处裸 catch。
- test:新增四个回归用例(401/403/503/连接失败),断言原始错误对象抵达
调用方;另加一条非合思租户的守卫用例。
This commit is contained in:
1 parent
8ecadbb124
commit
c572cba842
3 files changed
+131
-6
No files matched your search
+7
-1
@@ -97,7 +97,13 @@ function isValidationIssueList(error: unknown): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function responseStatus(error: unknown): number | undefined {
|
||||
/**
|
||||
* Read the HTTP status off an error thrown by the HTTP layer, structurally:
|
||||
* ky's `HTTPError` is not a dependency of this module, and test doubles only
|
||||
* carry `{ response: { status } }`. `undefined` means the request never got a
|
||||
* response (DNS failure, connection reset, timeout).
|
||||
*/
|
||||
export function responseStatus(error: unknown): number | undefined {
|
||||
if (!error || typeof error !== "object") return undefined;
|
||||
const response = (error as { response?: unknown }).response;
|
||||
if (!response || typeof response !== "object") return undefined;
|
||||
|
||||
Reference in new issue
Block a user