limingxinleo
changed the title
Fix Nacos V2 and V3 instance list response parsing
Support nacos v1 v2 and v3 for reading hosts from instance list.
Aug 7, 2026
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
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.
修改内容
问题原因
Nacos V3 使用统一响应结构,将实例数组放在 data 字段中。当前代码只读取
顶层 hosts 字段,因此使用 Nacos V3 进行服务发现时无法取得任何节点。
本次修改同时保留 V1 兼容性,并覆盖 Nacos 官方文档定义的 V2 响应结构。
测试
18 个测试,32 个断言全部通过。
修复 #7571。
同时解决 #7542 中服务发现响应解析的部分;服务注册和心跳续约不在本次
PR 的修改范围内。