Aias00 opened a new pull request, #3536:
URL: https://github.com/apache/dubbo-go/pull/3536

   ## What
   
   `PassThroughProxyInvoker.Invoke` and the generic `service_filter` 
dereference `common.ServiceMap.GetServiceByServiceKey(...).Method()` without a 
nil check, panicking when the service key is not registered. The default 
`ProxyInvoker` already guards this.
   
   ## Why
   
   ```go
   // common/rpc_service.go GetServiceByServiceKey — returns nil when not 
registered
   if s, ok := sm.serviceMap[protocol]; ok {
       if srv, ok := s[serviceKey]; ok { return srv }
       return nil
   }
   return nil
   ```
   
   ```go
   // filter/generic/service_filter.go:83-84 (before)
   svc := common.ServiceMap.GetServiceByServiceKey(ivkURL.Protocol, 
ivkURL.ServiceKey())
   method := svc.Method()[mtdName]   // nil deref
   
   // proxy/proxy_factory/pass_through.go:89,103 (before)
   srv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, 
url.ServiceKey())
   ...
   method := srv.Method()["Service"]   // nil deref
   ```
   
   The default invoker guards it (`proxy/proxy_factory/default.go:111-115`); 
these two do not. A generic (`$invoke`) or pass-through invocation for an 
unregistered service key (dynamic re-export desync, post-unexport, protocol 
mismatch) crashes the provider goroutine instead of returning an error.
   
   ## Fix
   
   Mirror the default invoker's guard in both call sites — return a clear 
"service not found" error instead of nil-derefing.
   
   ## Tests
   
   Added a `TestPassThroughProxyInvoker_Invoke` sub-test "service not 
registered returns error instead of panicking" using a never-registered 
protocol/interface, asserting the result is an error (no panic). 
`proxy/proxy_factory` and `filter/generic` pass under `-race`.
   
   Fixes #3535


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