XTLS/Xray-core · error
Upstream sent malformed statistics.
Error message
Upstream sent malformed statistics.
What it means
A value received on the routing stats channel failed the routing.Route type assertion. The channel contract expects only Route values, so this indicates an internal invariant break or cross-version mismatch between publisher and subscriber.
Source
Thrown at app/router/command/command.go:125
func (s *routingServer) SubscribeRoutingStats(request *SubscribeRoutingStatsRequest, stream RoutingService_SubscribeRoutingStatsServer) error {
if s.routingStats == nil {
return errors.New("Routing statistics not enabled.")
}
genMessage := AsProtobufMessage(request.FieldSelectors)
subscriber, err := stats.SubscribeRunnableChannel(s.routingStats)
if err != nil {
return err
}
defer stats.UnsubscribeClosableChannel(s.routingStats, subscriber)
for {
select {
case value, ok := <-subscriber:
if !ok {
return errors.New("Upstream closed the subscriber channel.")
}
route, ok := value.(routing.Route)
if !ok {
return errors.New("Upstream sent malformed statistics.")
}
err := stream.Send(genMessage(route))
if err != nil {
return err
}
case <-stream.Context().Done():
return stream.Context().Err()
}
}
}
func (s *routingServer) mustEmbedUnimplementedRoutingServiceServer() {}
type service struct {
v *core.Instance
}
func (s *service) Register(server *grpc.Server) {View on GitHub (pinned to 7d214f8b09)
Solutions
- Ensure only router.Route values are published to the routing stats channel
- Clean go.mod/vendor of duplicate or mismatched xray-core versions and rebuild
- Report upstream if reproducible on an unmodified build
Defensive patterns
Strategy: type-guard
Type guard
func asRoute(v interface{}) (routing.Route, bool) {
r, ok := v.(routing.Route)
return r, ok
} Prevention
- Never publish non-Route values to the routing stats channel
- Keep a single xray-core version across the build graph (go mod graph check)
- Treat occurrence as a build-integrity incident, not a runtime condition to swallow
When it happens
Trigger: Something other than routing.Route is published to the routing stats channel (custom publisher, corrupted build, mixed core versions linking different Route types).
Common situations: Forks publishing custom types to the same channel; vendoring two xray-core versions so routing.Route differs per package; extremely unlikely in stock builds.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unsupported router implementation
- Routing statistics not enabled.
- Upstream closed the subscriber channel.
- user account is not valid
- can't get inbound proxy from handler.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/57a0ef835a0697cb.
Report an issue: GitHub.