Lcos-000 opened a new issue, #3683:
URL: https://github.com/apache/dubbo-go/issues/3683
### Description
Follow-up to #3680.
`RPCInvocation.ActualMethodName()`
(`protocol/invocation/rpcinvocation.go:85-91`) performs an unguarded type
assertion on the first generic-call argument:
```go
func (r *RPCInvocation) ActualMethodName() string {
if r.IsGenericInvocation() {
return r.Arguments()[0].(string) // panics if arg[0] is not a
string
} else {
return r.MethodName()
}
}
```
`IsGenericInvocation()` only checks `len(Arguments)==3`, not the element
types. A malformed `$invoke` with a non-string `arg[0]` reaches this line and
panics with `interface conversion: interface {} is X, not string`.
### Reproduction
```go
inv := invocation.NewRPCInvocation(constant.Generic,
[]any{123, []string{}, []hessian.Object{}},
map[string]{constant.GenericKey: "true"})
// inv.ActualMethodName() -> panic: interface conversion: interface {} is
int, not string
```
### Reachability
In the default `DefaultServiceFilters` chain, `genericServiceFilter` (fixed
by #3680) runs **before** `otelServerFilter` and short-circuits malformed
invocations, so `ActualMethodName()` is not reached. This is therefore **not
reachable by default**.
However, `otelServerFilter` is appended to the filter chain when
`otel.tracing.enable=true` (`server/action.go:388-389`), and the filter order
is user-configurable via the service/provider `filter` setting
(`server/action.go:380`). If a user places `otelServerTrace` before
`generic_service`, or omits `generic_service` from a custom chain, the panic
becomes reachable on the only server-side call site
(`filter/otel/trace/filter.go:83`).
The remaining 6 call sites are client-side (cluster invokers / loadbalance)
and handle locally-constructed invocations, so they are not externally
reachable.
### Affected call sites
| Location | Side | Reachable? |
|---|---|---|
| `filter/otel/trace/filter.go:83` (otelServerFilter.Invoke) | server | Only
with non-default filter ordering + tracing enabled |
| `filter/otel/trace/filter.go:126` (otelClientFilter.Invoke) | client | No |
| `cluster/cluster/failover/cluster_invoker.go:64` | client | No |
| `cluster/cluster/failfast/cluster_invoker.go:49` | client | No |
| `cluster/cluster/forking/cluster_invoker.go:66` | client | No |
| `cluster/cluster/zoneaware/cluster_invoker.go:88` | client | No |
| `cluster/loadbalance/p2c/loadbalance.go:118` | client | No |
### Environment
- dubbo-go version: `develop` @ `9757e773`
--
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]