Copilot commented on code in PR #3034:
URL: https://github.com/apache/dubbo-go/pull/3034#discussion_r2365561963


##########
protocol/grpc/client.go:
##########
@@ -139,8 +139,12 @@ func NewClient(url *common.URL) (*Client, error) {
        }
 
        key := url.GetParam(constant.InterfaceKey, "")
-       impl := config.GetConsumerServiceByInterfaceName(key)
-       invoker := getInvoker(impl, conn)
+       //TODO: Temporary compatibility with old APIs, can be removed later
+       consumerService := config.GetConsumerServiceByInterfaceName(key)
+       if rpcService, ok := url.GetAttribute(constant.RpcServiceKey); ok {
+               consumerService = rpcService

Review Comment:
   The code doesn't validate that `rpcService` is of the expected type before 
assignment. Consider adding type assertion to ensure the attribute value is 
compatible with the expected consumer service interface.
   ```suggestion
                typedService, ok := rpcService.(interface{})
                if !ok {
                        logger.Errorf("rpcService does not implement the 
expected consumer service interface")
                        return nil, errors.New("rpcService does not implement 
the expected consumer service interface")
                }
                consumerService = typedService
   ```



##########
protocol/triple/dubbo3_invoker.go:
##########
@@ -80,7 +80,11 @@ func NewDubbo3Invoker(url *common.URL) (*DubboInvoker, 
error) {
        // for triple pb serialization. The bean name from provider is the 
provider reference key,
        // which can't locate the target consumer stub, so we use interface 
key..
        interfaceKey := url.GetParam(constant.InterfaceKey, "")
+       //TODO: Temporary compatibility with old APIs, can be removed later
        consumerService := 
config.GetConsumerServiceByInterfaceName(interfaceKey)
+       if rpcService, ok := url.GetAttribute(constant.RpcServiceKey); ok {
+               consumerService = rpcService

Review Comment:
   The code doesn't validate that `rpcService` is of the expected type before 
assignment. Consider adding type assertion to ensure the attribute value is 
compatible with the expected consumer service interface.
   ```suggestion
                typedService, ok := rpcService.(interface{})
                if !ok {
                        return nil, errors.New("rpcService attribute is not of 
the expected type")
                }
                consumerService = typedService
   ```



-- 
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]

Reply via email to