From 1f16124edbea7625fe50416a7be80ece8990dafe Mon Sep 17 00:00:00 2001 From: ssw Date: Sat, 27 Jun 2026 10:03:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(webapi):=20B-1=20unwrap=20null=20=E8=BF=94?= =?UTF-8?q?=20stub=20{code,msg,id}=20=E9=98=B2=20TypeError?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dacli dict/dm/form/workflow create 命令原本在 JNPF 返 data:null 时抛 'Cannot read properties of undefined (reading code)'. unwrap 现返 {code:resp.code, msg:resp.msg, id:undefined} stub, 调用方 tr.code 不再崩, 通过 msg='New created successfully' 判断成功. 后续调用方应改用 GET API 验证实际状态 (避免假 PASS). tds 9 bug 复盘 2026-06-27 --- src/webapi/_defhttp_shim.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/webapi/_defhttp_shim.ts b/src/webapi/_defhttp_shim.ts index ab7854c..dccaf16 100644 --- a/src/webapi/_defhttp_shim.ts +++ b/src/webapi/_defhttp_shim.ts @@ -47,11 +47,34 @@ function cleanQuery(data: Record | undefined): Record(resp: { code: number; msg?: string; data: T | null }): Promise { if (resp.code !== 200) { throw new Error(`API code=${resp.code}: ${resp.msg ?? ''}`) } + if (resp.data === null || resp.data === undefined) { + // JNPF POST create-type 成功无 data → 返 stub 防 TypeError. + // 兼容所有调用方 cast `{code?, msg?, id?, data?}` 类型断言. + return { code: resp.code, msg: resp.msg, id: undefined } as unknown as T + } return resp.data as T }