You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/07/26 14:45:28 UTC

[I] [BUG] generic service_filter & pass_through proxy: nil-deref panic when GetServiceByServiceKey returns nil [dubbo-go]

Aias00 opened a new issue, #3535:
URL: https://github.com/apache/dubbo-go/issues/3535

   ### Problem
   
   `common.ServiceMap.GetServiceByServiceKey` returns `nil` when the protocol/serviceKey is not registered (`common/rpc_service.go:189-199`). The default `ProxyInvoker.Invoke` guards this (`proxy/proxy_factory/default.go:111-115`):
   
   ```go
   svc := common.ServiceMap.GetServiceByServiceKey(proto, url.ServiceKey())
   if svc == nil {
       logger.Errorf("[Proxy] cannot find service [%s] in %s", path, proto)
       result.SetError(perrors.Errorf("cannot find service [%s] in %s", path, proto))
       return result
   }
   ```
   
   Two other call sites dereference the result **without** a nil check:
   
   - `filter/generic/service_filter.go:83-84` (generic `$invoke` filter):
     ```go
     svc := common.ServiceMap.GetServiceByServiceKey(ivkURL.Protocol, ivkURL.ServiceKey())
     method := svc.Method()[mtdName]   // nil deref if svc == nil
     ```
   - `proxy/proxy_factory/pass_through.go:89,103` (`PassThroughProxyInvoker.Invoke`):
     ```go
     srv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey())
     ...
     method := srv.Method()["Service"]   // nil deref if srv == nil
     ```
   
   `(*Service).Method()` accesses `s.methods` with no nil receiver guard, so a nil `*Service` panics.
   
   ### Current behavior
   
   A generic (`$invoke`) invocation, or a `PassThroughProxyInvoker` invocation, that routes to a service key not present in `ServiceMap` (unregistered service, protocol key mismatch, exporter/service-map desync during dynamic re-export, or an invocation arriving during/after unexport) crashes the provider goroutine with a nil-pointer panic instead of returning an error.
   
   ### Expected behavior
   
   Both call sites should nil-check `GetServiceByServiceKey`'s result and return a clear error, matching the default `ProxyInvoker`.
   
   ### Suggested approach
   
   Mirror the default invoker's guard:
   
   ```go
   svc := common.ServiceMap.GetServiceByServiceKey(proto, serviceKey)
   if svc == nil {
       return error  // "service ... is not found, protocol: ..."
   }
   ```
   
   in `filter/generic/service_filter.go` (return `*result.RPCResult{Err: ...}`) and `proxy/proxy_factory/pass_through.go` (set `result.Err` and return).
   
   ### Acceptance criteria
   
   - [ ] `filter/generic/service_filter.go` nil-checks `svc` before `svc.Method()`.
   - [ ] `proxy/proxy_factory/pass_through.go` nil-checks `srv` before `srv.Method()["Service"]`.
   - [ ] A regression test asserts an unregistered service returns an error instead of panicking.
   - [ ] Existing generic / proxy tests remain green.
   


-- 
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: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [BUG] generic service_filter & pass_through proxy: nil-deref panic when GetServiceByServiceKey returns nil [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on issue #3535:
URL: https://github.com/apache/dubbo-go/issues/3535#issuecomment-5086257211

   not planned


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


Re: [I] [BUG] generic service_filter & pass_through proxy: nil-deref panic when GetServiceByServiceKey returns nil [dubbo-go]

Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl closed issue #3535: [BUG] generic service_filter & pass_through proxy: nil-deref panic when GetServiceByServiceKey returns nil
URL: https://github.com/apache/dubbo-go/issues/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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org