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: failed to read gRPC API Configuration description: no such file or directory HOT 1
- Moving protos out of protoc-gen-openapiv2/options directory to support Python HOT 3
- Grpc gateway project starter script HOT 1
- Support Service doc comments for OpenApi/Swagger generation HOT 4
- [Feature Request] Provide a legit way to override HTTP Response. HOT 7
- How to get HTTP headers in custom Marshaller? HOT 1
- streaming response does not return text/event-stream content-type HOT 14
- Define "CustomHttpPattern" under "google.api.http", using the plug-in protoc-gen-openapiv2 encountered no swagger documentation generated. HOT 1
- Support Protobuf Editions HOT 7
- Dealing with 304 response without printing errors HOT 5
- How to pass the error 400 in fieldmask if a unknow field is send? HOT 1
- google.protobuf.Empty as response serializes to not empty response on REST client depending on request headers HOT 4
- ERROR: Failed to extract ServerMetadata from context HOT 13
- Placement for unique items in array type is located in the wrong place HOT 1
- Support explicit omitempty annotation in proto HOT 1
- gateway to multiple grpc services defined in two different files HOT 3
- bug: URL Query parameter not bind to `Optional` proto message field HOT 3
- How can register multiple gRPC services in `main.go` at the same time? HOT 1
- Feature request: virtual oneof property HOT 3
- Unable to mark the body parameter as REQUIRED when part of the proto message is path param HOT 2
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.