Copilot commented on code in PR #3364:
URL: https://github.com/apache/dubbo-go/pull/3364#discussion_r3340744025
##########
metadata/client.go:
##########
@@ -53,7 +53,15 @@ func GetMetadataFromMetadataReport(revision string, instance
registry.ServiceIns
func GetMetadataFromRpc(revision string, instance registry.ServiceInstance)
(*info.MetadataInfo, error) {
url := buildStandardMetadataServiceURL(instance)
url.SetParam(constant.TimeoutKey, defaultTimeout)
- p := extension.GetProtocol(url.Protocol)
+ p, err := extension.GetProtocolWithError(url.Protocol)
Review Comment:
`buildStandardMetadataServiceURL` can return nil when the instance metadata
doesn't contain a protocol (see `buildStandardMetadataServiceURL` returning nil
when `ps[constant.ProtocolKey] == ""`). `GetMetadataFromRpc` dereferences `url`
immediately (`url.SetParam(...)`), which will still panic on that path.
Consider returning a descriptive error instead so missing/invalid metadata
doesn't crash the consumer.
--
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]