You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "qiubyte (via GitHub)" <gi...@apache.org> on 2026/01/09 05:28:02 UTC
[I] [BUG] [dubbo-go]
qiubyte opened a new issue, #3157:
URL: https://github.com/apache/dubbo-go/issues/3157
### ✅ 验证清单
- [x] 🔍 我已经搜索过 [现有 Issues](https://github.com/apache/dubbo-go/issues),确信这不是重复问题
### 🚀 Go 版本
1.24.0
### 📦 Dubbo-go 版本
v3.3.1
### 🖥️ 服务端配置
dubbo-go v3.3.1
### 💻 客户端配置
terminal curl http
### 🌐 协议配置
triple
### 📋 注册中心配置
nacos v3
### 💾 操作系统
🍎 macOS
### 📝 Bug 描述
问题现象:dubbo-go 使用triple协议暴露服务,希望通过http方式调用传递参数并获取返回值。
错误信息:http body中json数据多传递了参数,或者说有些字段以前存在,现在从proto中被移除了,但是调用端还可能在使用,就会出现invalid_argument的错误。
### 🔄 重现步骤
步骤
1. 定义接收参数
`type GsImportReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
DeviceId *string `protobuf:"bytes,1,opt,name=deviceId,proto3,oneof" json:"deviceId,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}`
2. curl 发起http调用
`
正确:
curl -H "Content-Type:application/json" -H "tri-service-group:uac" -H "tri-service-version:1.0.0" -X POST --data '{"deviceId":"tas"}' "http://127.0.0.1:50001/com.cc.uac.facade.UacGsInternalFacade/GsImport"
多加了参数就报错:
curl -H "Content-Type:application/json" -H "tri-service-group:uac" -H "tri-service-version:1.0.0" -X POST --data '{"deviceId":"tas","plat":"saas"}' "http://127.0.0.1:50001/com.cc.uac.facade.UacGsInternalFacade/GsImport"
`
### ✅ 预期行为
期望能收到正确的业务返回值
### ❌ 实际行为
实际provider端返回错误信息。{"code":"invalid_argument","message":"unmarshal into *GsImportReq: proto: (line 1:24): unknown field \"plat\""}
### 💡 可能的解决方案
跟踪代码发现 triple_protocol/codec.go 中使用到 protojson.UnmarshalOptions DiscardUnknown 默认为false,会严格比对参数。
`
func (c *protoJSONCodec) Unmarshal(binary []byte, message any) error {
protoMessage, ok := message.(proto.Message)
if !ok {
return errNotProto(message)
}
if len(binary) == 0 {
return errors.New("zero-length payload is not a valid JSON object")
}
var options protojson.UnmarshalOptions
return options.Unmarshal(binary, protoMessage)
}
`
var options protojson.UnmarshalOptions 是否可以添加DiscardUnknown: true,或者通过配置方式让使用者自己决定要不要严格限制
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] http调用忽略不存在的参数 [dubbo-go]
Posted by "CAICAIIs (via GitHub)" <gi...@apache.org>.
CAICAIIs commented on issue #3157:
URL: https://github.com/apache/dubbo-go/issues/3157#issuecomment-3765459288
经社区讨论后是不打算实现了:参数多了报错也没啥问题,参数都改了改升v2了
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] http调用忽略不存在的参数 [dubbo-go]
Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks closed issue #3157: [BUG] http调用忽略不存在的参数
URL: https://github.com/apache/dubbo-go/issues/3157
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] http调用忽略不存在的参数 [dubbo-go]
Posted by "qiubyte (via GitHub)" <gi...@apache.org>.
qiubyte commented on issue #3157:
URL: https://github.com/apache/dubbo-go/issues/3157#issuecomment-3736622462
> 复现发现问题确实存在。我觉得 通过配置方式让使用者自己决定要不要严格限制 这个方案挺好的,如果可以的话请 assign 给我去实现。代码量并不多
ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [I] [BUG] http调用忽略不存在的参数 [dubbo-go]
Posted by "CAICAIIs (via GitHub)" <gi...@apache.org>.
CAICAIIs commented on issue #3157:
URL: https://github.com/apache/dubbo-go/issues/3157#issuecomment-3734703652
我觉得 通过配置方式让使用者自己决定要不要严格限制 这个方案挺好的,如果可以的话请 assign 给我去实现。代码量并不多
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org