Skip to content

Feat(generic):safe param decode by metadata - #1647

Open
Snow-kal wants to merge 3 commits into
apache:developfrom
Snow-kal:feat/safe-param-decode-by-metadata
Open

Snow-kal wants to merge 3 commits into
apache:developfrom
Snow-kal:feat/safe-param-decode-by-metadata

Conversation

@Snow-kal

Copy link
Copy Markdown

Please provide a description of this PR:
修复 Dubbo Admin 泛化调用中的大整数精度丢失和重载参数校验问题
关联 issue apache/dubbo-go#3742 第 3 项。

  1. 按 provider 和完整签名匹配重载
    根据所选实例所属的 provider 应用、方法名和完整 signature 查找方法声明。匹配后,复用现有 method detail 和 buildRelatedTypes,从同一份 provider metadata 获取参数顺序、参数类型和嵌套字段定义

例如,同一服务同时声明 echo(long) 和 echo(User) 时,选择 echo(User) 后提交数字,Admin 会在发起 RPC 前返回类型错误。提交仅由其他 provider 声明的签名,也会在方法匹配阶段失败

  1. 保留原始 JSON 数字,按目标类型解码
    前端校验编辑器中的 JSON 语法后,保留原始数字文本构造请求体。后端沿用 []json.RawMessage 接收参数,并使用 json.Number 将数值转换延迟到目标类型确定之后,避免大整数经过 JavaScript Number 或 Go float64 时发生舍入

解码覆盖 Java/Go 标量、Java 装箱类型、java.math.BigInteger、数组、枚举、嵌套对象和 map。数组元素、对象字段以及 map 的键和值均按各自的类型递归校验。例如,long 参数输入 "9223372036854775807" 时会精确转换为 int64;输入 "9223372036854775808" 时会在发起 RPC 前返回越界错误。

  1. 在调试页展示重载和字段级错误
    方法标签展示参数类型,例如 echo(long) 和 echo(User)。切换重载后,调试页根据当前签名重新生成请求模板。long、int64 和 BigInteger 等类型默认使用带引号的十进制字符串。快速切换时,较早发出的详情请求即使后返回,也不会覆盖当前模板。

参数错误会在响应区显示完整字段路径、期望类型、实际类型和失败原因。例如:

  • 缺少嵌套字段:user.profile.id: expected long, got missing (required field)
  • 枚举值非法:user.profile.role: expected Role, got string (allowed values: ADMIN, USER)
    现有 metadata 没有独立的必填标记,本次按 properties 检查字段是否存在。对于 null,按字段类型单独处理,例如 Java 装箱类型允许显式传入 null。

To help us figure out who should review this PR, please put an X in all the areas that this PR affects.

  • Docs
  • Installation
  • User Experience
  • Dubboctl
  • Console
  • Core Component

…tadata

Preserve numeric tokens until the selected scalar type is known. Validate nested objects, collections and enums with field paths before invoking the RPC, and cover overload isolation and numeric wire boundaries.
…ctive overload

Generate long values as decimal strings, submit the original JSON tokens, and ignore stale method details. Exercise overload switching, request payloads and field errors in the debug view.
Copilot AI balanced review requested due to automatic review settings November 21, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants