Repository navigation
fix(minimax-bot): 没填的可选值当作没填,而不是当成非法值 - #159
Closed
Apageoflove wants to merge 1 commit into
Closed
Apageoflove wants to merge 1 commit into
Apageoflove wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
群的 reply mode 和定时任务的 kind 都会对着目录里给的那几个值校验,不在里面就拒掉,不会悄悄变成另一个。但没填的值也会被拒 —— 当它以 null 到达的时候。
模型把没填的可选字段写成 null 很常见,于是 create_group 带着 reply_mode: null 会被回一句「reply_mode must be one of: admin, all」。0.7.15 之前不是这样,那时 null 会走默认值。
原因是门口的校验把 null 当成没传跳过去了,然后 replyModeOf(null) 里 String(null) 得到 'null',不在允许值里,就抛了。
现在 null 被读成它本来的意思 —— 这个字段没填 —— 所以走默认值,跟字段整个不传一样。在那儿但不对的值仍然拒:'everyone'、'hourly' 都不行,字符串 'null' 也不行。
改的是三处:createGroup 的 reply mode、updateGroup 的 reply mode、saveSchedule 的 kind。已有群用 null 更新时保持原来的 mode 不变。
测试加了三条:null 的 reply mode 建群得到 admin,null 的 kind 建任务得到 daily,而错的两个值仍然被拒;再加一条确认已有群用 null 更新时 mode 不变。这两条在未改的 main 上是红的。全量 429 条过。
版本号 0.7.40。0.7.37 在 #148 上,0.7.38 在 #157 上,0.7.39 在 #156 上。
验证范围:只有 Node 22 上的测试是实测的。真实 Host 和 Electron 我没跑过 —— 这一层是仅个人判断。
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.