Skip to content

Commit 56f7b06

Browse files
committed
fix(cli): surface a refusal body's own hint and size numbers
failHttp only echoed data.error, so an over-limit share pack (413 with bytes, limitBytes and a server-authored hint) reached the terminal as "HTTP 413: too-large" and lost both the numbers and the batching advice. The command side must not grow a second error branch for it, and the full report already reaches stdout-capable callers through --json's rawJson passthrough.
1 parent 8682e02 commit 56f7b06

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎dsh-mneme/bin/cli.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ function failHttp(cfg, status, pathname, data, text) {
246246
} else if (status === 404) {
247247
hint = `\n资源不存在:${pathname}`;
248248
}
249+
// 拒答体自己带的下一步必须转出去,不然命令侧只能再写一份错误分支。撞上的这一刀是
250+
// share 的 413:响应体是 {error:"too-large", bytes, limitBytes, hint, report},
251+
// 旧实现只取 data.error,于是现场只剩「请求失败(HTTP 413):too-large」——「大了
252+
// 多少」与「用 --type/--tag 分批」那两句留在体里没人看得见(措辞只许有一份,就在
253+
// 拒发的那侧,同 RECLAIM_CONFIRM_HINT 的口径)。完整 report(含 skip_list)走
254+
// --json:下面 rawJson 把整个响应体原样交给 stderr,这里不复制第二份打印器。
255+
if (data && typeof data === 'object') {
256+
if (typeof data.hint === 'string' && data.hint.trim()) hint += `\n${data.hint.trim()}`;
257+
if (Number.isFinite(data.bytes) && Number.isFinite(data.limitBytes)) {
258+
hint += `\n量到 ${formatBytes(data.bytes)},水位 ${formatBytes(data.limitBytes)}`;
259+
}
260+
}
249261
fail(cfg, `请求失败(HTTP ${status})${serverError ? `:${serverError}` : ''} [${pathname}]${hint}`, {
250262
rawJson: cfg.jsonMode && text ? text : undefined,
251263
});

0 commit comments

Comments
 (0)