fix(channels): account_clear_credentialless 尊重 dry_run(args=req 回退吃掉 body)

## 真实缺陷(我自己在上一个提交里引入,部署后实测踩到)
handler 开头照其它 18 处写了 `if args.platform == nil then args = req end`。
但本函数**不传 platform 是合法用法**(清全部平台)⇒ args.platform 自然为 nil
⇒ args 被换成 HandlerRequest ⇒ 刚解出来的 dry_run 就丢了 ⇒
**传 dry_run=false 却被当成未传,静默只预演**。

破坏性操作里这是最糟的形态:操作者以为执行了、实际没执行(反过来同样危险)。
实测:不带 platform 时 deleted 恒为 nil,池子一个没动。

## 修法
兜底只认「req 本身就是参数表」这种形态(`req.body == nil and req.query == nil`),
不再用「某字段为 nil」当判据 —— 那个字段为 nil 可能只是本次调用**合法地没用它**。

## ★ 判据为什么第一版没咬住
我原来的夹具用 **map body** 调 Call,而缺陷只在**字符串 body**(HTTP 真实路径)
上暴露 —— `bodyOf` 对 table 直接返回,根本走不到回退那行。
补 `TestAccountClearCredentiallessRespectsDryRunViaStringBody`(用
`InvokeHandler` + 字符串 body + 不传 platform)后变异才咬住。
**教训:夹具的调用形态必须与生产一致 —— 用 map 便捷调用会绕过 body 解析路径。**

判据 4 条(含本条)+ 变异 3/3。
This commit is contained in:
JianFeeeee
2026-10-16 07:51:21 +08:00
parent 1f18643d1f
commit 7c82c7ff6b
2 changed files with 49 additions and 1 deletions

View File

@ -6440,7 +6440,15 @@ end
function plugin.account_clear_credentialless(req)
local args = bodyOf(req)
if args.platform == nil then args = req end
-- ⚠️ 不要照其它 handler 写 `if args.platform == nil then args = req end`:
-- 那个回退是为「直接把参数当 req 传」的旧调用准备的,但它会**丢掉 body**
-- —— 本函数不传 platform 是**合法用法**(清全部平台),此时 args.platform
-- 自然为 nil,回退会把 args 换成 HandlerRequest ⇒ 刚解出来的 dry_run 就没了,
-- 于是「传 dry_run=false 却被当成未传」而静默只预演(破坏性操作里最糟的形态:
-- 操作者以为执行了、实际没执行,或者反过来)。
-- 实测踩到:不带 platform 时 deleted 恒为 nil。
-- 兜底只认「req 本身就是参数表」这种形态。
if type(req) == "table" and req.body == nil and req.query == nil then args = req end
local dry = args.dry_run
if dry == nil then dry = true end