xxs588 opened a new issue, #3398: URL: https://github.com/apache/dubbo-go/issues/3398
### ✅ 验证清单 - [x] 🔍 我已经搜索过 [现有 Issues](https://github.com/apache/dubbo-go/issues),确信这不是重复问题 - [x] 📚 我已对照 dubbo-go 源码进行溯源 ### 🚀 Go 版本 go1.25.6 linux/amd64 ### 📦 Dubbo-go 版本 upstream main (e6e14fd3) ### 💾 操作系统 🐧 Linux ### 📝 Bug 描述 在溯源 Tag Router 端到端不可用问题([#3397](https://github.com/apache/dubbo-go/issues/3397))的过程中,发现 `MetadataInfo.Tag` 字段存在两个序列化层面的缺陷,可能导致 `application.tag` 在 metadata 存储/传输过程中丢失。 **问题 1:`MetadataInfo.Tag` 缺少 JSON 和 Hessian 序列化 tag** 文件:`metadata/info/metadata_info.go:60-66` ```go type MetadataInfo struct { App string `json:"app,omitempty" hessian:"app"` Revision string `json:"revision,omitempty" hessian:"revision"` Tag string // ← 缺少 json 和 hessian tag Services map[string]*ServiceInfo `json:"services,omitempty" hessian:"services"` } ``` `App` 和 `Revision` 都有 `json` 和 `hessian` tag,但 `Tag` 没有。通过 hessian 序列化的 RPC 路径(如 Triple 协议的 metadata report)会丢失 Tag。 **问题 2:`convertMetadataInfoV2` 未映射 Tag 字段** 文件:`metadata/client.go:94-113` ```go func convertMetadataInfoV2(v2 *tripleapi.MetadataInfoV2) *info.MetadataInfo { // ... metadataInfo := &info.MetadataInfo{ App: v2.App, Revision: v2.Version, Services: infos, // Tag 字段未设置! } return metadataInfo } ``` 当 consumer 通过 Triple RPC 获取 provider 的 metadata 时,`Tag` 字段没有从 proto 消息映射过来。 ### 🔄 重现步骤 1. 读取 `metadata/info/metadata_info.go` 第 60-66 行,确认 `Tag` 字段缺少序列化 tag 2. 读取 `metadata/client.go` 第 94-113 行,确认 `convertMetadataInfoV2` 未映射 Tag 3. 启动带 `application.tag=gray` 的 provider,通过 Triple RPC 获取其 metadata 4. 检查返回的 `MetadataInfo.Tag` 是否为空 ### ✅ 预期行为 1. `MetadataInfo.Tag` 应有 `json:"tag,omitempty"` 和 `hessian:"tag"` tag,确保序列化/反序列化不丢失 2. `convertMetadataInfoV2` 应从 proto 消息中映射 Tag 字段 ### ❌ 实际行为 1. `Tag` 字段缺少序列化 tag,hessian 路径会丢失 2. `convertMetadataInfoV2` 不映射 Tag,Triple RPC 路径会丢失 ### 💡 可能的解决方案 ```go // 修复 1:metadata/info/metadata_info.go Tag string `json:"tag,omitempty" hessian:"tag"` // 修复 2:metadata/client.go convertMetadataInfoV2 metadataInfo := &info.MetadataInfo{ App: v2.App, Revision: v2.Version, Tag: v2.Tag, // ← 添加 Services: infos, } ``` ### 📎 关联 Issue - #3397 — Tag Router 端到端不可用(主问题) - #3203 (OPEN) — Router 状态总览 ### 验收标准 - [ ] `MetadataInfo.Tag` 有正确的 `json` 和 `hessian` 序列化 tag - [ ] `convertMetadataInfoV2` 正确映射 Tag 字段 - [ ] 通过 hessian 和 Triple RPC 两种路径获取的 metadata 都包含 Tag -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
