utrack / clay

Proto-first minimal server platform for gRPС+REST+Swagger APIs
MIT License
290 stars 37 forks source link

Get The reflect error in example #88

Closed zengzhengrong closed 4 years ago

zengzhengrong commented 4 years ago

I browse swagger ui and input a ,b ,I get this error ,

oot@9de65925afcf:/workspaces/example# go run main.go 
go: finding module for package github.com/utrack/clay/v2/transport/httptransport
go: finding module for package github.com/utrack/clay/v2/transport/httpclient
go: found github.com/utrack/clay/v2/transport/httpclient in github.com/utrack/clay/v2 v2.4.7
2020/06/05 16:26:12 http: panic serving 127.0.0.1:59764: reflect: call of reflect.Value.Type on zero Value
goroutine 51 [running]:
net/http.(*conn).serve.func1(0xc00017e000)
        /usr/local/go/src/net/http/server.go:1772 +0x139
panic(0xa01be0, 0xc0003ea5e0)
        /usr/local/go/src/runtime/panic.go:975 +0x3e3
reflect.Value.Type(0x0, 0x0, 0x0, 0x30, 0xa95320)
        /usr/local/go/src/reflect/value.go:1872 +0x183
github.com/golang/protobuf/jsonpb.(*Unmarshaler).unmarshalValue(0xc0003ea560, 0x0, 0x0, 0x0, 0xc0003ca890, 0x10, 0x10, 0x0, 0x40e478, 0x20)
        /go/pkg/mod/github.com/golang/protobuf@v1.3.2/jsonpb/jsonpb.go:720 +0x5d
github.com/golang/protobuf/jsonpb.(*Unmarshaler).UnmarshalNext(0xc0003ea560, 0xc0000ec6e0, 0xca8260, 0x0, 0x0, 0xa08301)
        /go/pkg/mod/github.com/golang/protobuf@v1.3.2/jsonpb/jsonpb.go:682 +0x166
github.com/grpc-ecosystem/grpc-gateway/runtime.decodeJSONPb(0xc0000ec6e0, 0xa7a880, 0x0, 0xcb4a01, 0xc0000ec6e0)
        /go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.2/runtime/marshal_jsonpb.go:176 +0xa5
github.com/grpc-ecosystem/grpc-gateway/runtime.DecoderWrapper.Decode(0xc0000ec6e0, 0xa7a880, 0x0, 0xca8260, 0x0)
        /go/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.14.2/runtime/marshal_jsonpb.go:149 +0x3f
github.com/utrack/clay/v2/transport/httpruntime.MarshalerPbJSON.Unmarshal(0x10db300, 0x10db340, 0x10db380, 0x10d9c00, 0x7f0c15b30d68, 0xc0000b9340, 0xa7a880, 0x0, 0xca9200, 0x7f0c15b30d68)
        /go/pkg/mod/github.com/utrack/clay/v2@v2.4.7/transport/httpruntime/mjson.go:59 +0x25f
github.com/utrack/clay/doc/example/pb.glob..func2.1(0xa81180, 0xc0003b09f0, 0xc0001cb788, 0x40e478)
        /workspaces/example/pb/sum.pb.goclay.go:234 +0x2a9
github.com/utrack/clay/doc/example/pb._Summator_Sum_Handler(0xa12880, 0x1106250, 0xcaa4a0, 0xc0003b09c0, 0xc0003a8440, 0xc0003b0060, 0x80, 0x80, 0xa950a0, 0xc000080000)
        /workspaces/example/pb/sum.pb.go:209 +0x53
github.com/utrack/clay/doc/example/pb.(*SummatorDesc).RegisterHTTP.func1(0xca8360, 0xc0000b93c0, 0xc0000c0600)
        /workspaces/example/pb/sum.pb.goclay.go:108 +0xe8
net/http.HandlerFunc.ServeHTTP(...)
        /usr/local/go/src/net/http/server.go:2012
github.com/utrack/clay/v2/transport/httpruntime/httpmw.HeadersToGRPCMD.func1(0xca8360, 0xc0000b93c0, 0xc0000c0500)
        /go/pkg/mod/github.com/utrack/clay/v2@v2.4.7/transport/httpruntime/httpmw/headers.go:45 +0x3d1
net/http.HandlerFunc.ServeHTTP(...)
        /usr/local/go/src/net/http/server.go:2012
github.com/utrack/clay/v2/transport/httpruntime/httpmw.InjectTransportStream.func1(0xca8be0, 0xc0000b2380, 0xc0000c0400)
        /go/pkg/mod/github.com/utrack/clay/v2@v2.4.7/transport/httpruntime/httpmw/headers.go:57 +0x23b
net/http.HandlerFunc.ServeHTTP(0xc0003a8140, 0xca8be0, 0xc0000b2380, 0xc0000c0400)
        /usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0000c26c0, 0xca8be0, 0xc0000b2380, 0xc0000c0400)
        /go/pkg/mod/github.com/go-chi/chi@v3.3.4+incompatible/mux.go:424 +0x278
net/http.HandlerFunc.ServeHTTP(0xc0003a80e0, 0xca8be0, 0xc0000b2380, 0xc0000c0400)
        /usr/local/go/src/net/http/server.go:2012 +0x44
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc0000c26c0, 0xca8be0, 0xc0000b2380, 0xc00017c400)
        /go/pkg/mod/github.com/go-chi/chi@v3.3.4+incompatible/mux.go:81 +0x2b2
net/http.serverHandler.ServeHTTP(0xc0000b20e0, 0xca8be0, 0xc0000b2380, 0xc00017c400)
        /usr/local/go/src/net/http/server.go:2807 +0xa3
net/http.(*conn).serve(0xc00017e000, 0xcaa3e0, 0xc000068000)
        /usr/local/go/src/net/http/server.go:1895 +0x86c
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2933 +0x35c

grpc client run correctly

utrack commented 4 years ago

Hi, thanks for the report! It seems that pb definitions were generated using old protoc-gen-go; I've regenerated them and now example works on latest master.

Can you please verify that it works for you now?

zengzhengrong commented 4 years ago

@utrack Thanks ~!