fix: 命令与表单错误处理 - #2
Merged
Merged
Conversation
基岩版 1.21+ 中 label/divider 会占据 formValues 槽位(值为 undefined), 而 InputForm 原先生成字段时只保留值字段做长度校验,导致使用 LabelField 时 values.length !== fields.length,提交报字段长度不匹配并重开表单。 改为保留全部字段与 formValues 槽位对齐,解析循环跳过非值字段。 Co-Authored-By: Claude <noreply@anthropic.com>
覆盖:保留全部字段与 formValues 槽位对齐、解析循环跳过展示字段、 必填校验按槽位定位、长度不匹配拦截、取消路径。修复 39cd087 无测试覆盖的遗留风险。 Co-Authored-By: Claude <noreply@anthropic.com>
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.
摘要
RawMessage对象,避免 ScriptAPI 原生类型转换失败。show()中预期的FormRejectError拒绝,同时让表单 builder/handler 的真实错误继续抛出。formValues槽位对齐,解析循环跳过非值字段。根本原因
未知命令路径向
Player.sendMessage传入了原始数组,而 ScriptAPI 期望的是字符串或RawMessage对象;玩家在响应前离开导致的表单拒绝错误也会变成未处理的 Promise 拒绝。
验证
npx tsgo -p tsconfig.build.json --noEmitnpx tsgo -p tsconfig.json --noEmitnpx vitest run(98 个测试全部通过)