Comments (13)
@gyuho
I am not yet confident but I suspect if this proto
in (*WatchRequest).XXX_OneofFuncs
,
func (*WatchRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) {
at https://github.com/gyuho/etcd/blob/3108859828f851e9a46772fe8e16d257b40f3639/etcdserver/etcdserverpb/rpc.pb.go#L1084
should have been github.com/golang/protobuf/proto
but not github.com/gogo/protobuf/proto
so that it is compatible to https://github.com/golang/protobuf/blob/ba6f978a1a6606adf3ccb6987f15c64262bfdbc2/proto/properties.go#L729.
from grpc-gateway.
Use of https://godoc.org/github.com/golang/protobuf/jsonpb instead of encoding/json can help.
from grpc-gateway.
@johansja Thank you. Yes, it is #79.
from grpc-gateway.
@yugui etcd is hitting this issue, though it's happening only in experimental feature.
Do we have any workaround for this? Or ETA to support this?
Thanks!
from grpc-gateway.
You should be able to use one_of
with the help of runtime.WithMarshalerOption
.
from grpc-gateway.
Now the default marshaller uses 'jsonpb'. So I think it is supported.
- https://github.com/gengo/grpc-gateway/blob/master/examples/browser/a_bit_of_everything_service.spec.js#L81
- https://travis-ci.org/gengo/grpc-gateway/jobs/137727616#L1049
@gyuho Could you re-confirm with the HEAD of the master branch?
Let me know if you still have the issue.
I'll close this issue if otherwise.
from grpc-gateway.
@yugui First thanks for helping debug this.
etcd still complains {"Error":"json: cannot unmarshal object into Go value of type etcdserverpb.isWatchRequest_RequestUnion","Code":2}
. And tried the latest master branch of grpc-gateway and golang/protobuf, and regenerate the gateway files, as here etcd-io/etcd@8759230.
I added reflect.TypeOf(marshaler)
to this line https://github.com/gyuho/etcd/blob/3108859828f851e9a46772fe8e16d257b40f3639/etcdserver/etcdserverpb/rpc.pb.gw.go#L91 and confirm that *runtime.JSONPb
typed marshaler is being used, but still seeting that error.
*runtime.JSONPb
2016-07-06 22:07:13.861689 I | v3rpc/grpc: Failed to decode request: json: cannot unmarshal object into Go value of type etcdserverpb.isWatchRequest_RequestUnion
Maybe we generate gateway files in the wrong way? I tried to regenerate *.gw.go
files but don't see any diff.
Thanks.
from grpc-gateway.
@gyuho I see. I'll take a look.
from grpc-gateway.
@gyuho
Does this work fine?
curl -L http://localhost:2379/v3alpha/watch -X POST -d '{"create_request": {"key": "Zm9v"}}'
You need to specify literally one of the fields grouped by request_union
.
from grpc-gateway.
@yugui Still doesn't seem to work.
curl -L http://localhost:2379/v3alpha/watch -X POST -d '{"create_request": {"key": "Zm9v"}}'
{"Error":"unknown field \"create_request\" in etcdserverpb.WatchRequest","Code":2}
Thanks!
from grpc-gateway.
@gyuho
It does not look to be an issue of grpc-gateway. I could reproduce the issue without grpc-gateway.
package main
import (
"log"
"github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/golang/protobuf/jsonpb"
)
func main() {
const input = `{"create_request": {"key": "Zm9v"}}`
var protoReq etcdserverpb.WatchRequest
if err := jsonpb.UnmarshalString(input, &protoReq); err != nil {
log.Fatal(err)
}
}
$ go run main.go
2016/07/12 12:15:28 unknown field "create_request" in etcdserverpb.WatchRequest
exit status 1
I don't know what the root cause actually is, but I suspect incompatibility between github.com/golang/protobuf/jsonpb
and gogoproto.
from grpc-gateway.
@gyuho Confirmed in https://gist.github.com/yugui/4425e705680fb4f6c99423b99b8a83d2
$ go get gist.github.com/4425e705680fb4f6c99423b99b8a83d2.git
$ go build -o test gist.github.com/4425e705680fb4f6c99423b99b8a83d2.git
$ ./test
$ echo $?
0
$ go build --tags=gogo -o test gist.github.com/4425e705680fb4f6c99423b99b8a83d2.git
$ ./test
2016/07/12 12:53:05 unknown field "create_request" in main.WatchRequest
$ echo $?
1
from grpc-gateway.
@yugui I will see if I can find some workarounds or file an issue to gogoproto. Thanks a lot!
from grpc-gateway.
Related Issues (20)
- Buf - Wrong import in grpcgateway HOT 1
- Document about how to mark an arrray field as required in an extra openapi config file? HOT 1
- multi-folder not generating correct swagger file HOT 2
- [protoc-gen-openapiv2] Option to disable setting default values for enums without omitting it from the list of values HOT 3
- openapiv2_tag.name does not work HOT 4
- Grpc Gateway discards Any typed fields HOT 2
- Populating query param semantics changed since v2.15.0 HOT 3
- When the body is set to a oneof field, other fields in the same group are included as query.
- For a field of type google.protobuf.Empty, FieldMaskFromRequestBody does not generate any fieldmask HOT 3
- generate swagger schema title and description failed HOT 2
- Issue with importing "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway" HOT 3
- genopenapi: Stable openapi names for nested types HOT 1
- snake_case response HOT 1
- api_visibility doesn't transitively apply to rpc request/response messages HOT 2
- protoc-gen-grpc-gateway and protoc-gen-openapiv2 return incorrect version HOT 1
- Dependency on google.golang.org/grpc/health/grpc_health_v1 conflicts with custom proto marshallers HOT 5
- JSONPb marshaler doesn't use indent on non proto fields
- WriteHeader is not called on 200s HOT 1
- How to set cookie to http response header? Why it doesn't work. HOT 2
- Adding custom mux endpoint to openapi output HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-gateway.