New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json: method descriptors don't have "type" field #528

Closed
paralin opened this Issue Dec 7, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@paralin

paralin commented Dec 7, 2016

Getting this error:

/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/util.js:66
    return TypeError(name + " must be " + (description || "a string"));
           ^
TypeError: type (is undefined) [undefined] must be a string
    at TypeError (native)
    at util._TypeError (/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/util.js:66:12)
    at new Method (/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/method.js:36:15)
    at Function.fromJSON (/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/method.js:105:12)
    at /home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/service.js:80:32
    at Array.forEach (native)
    at Function.fromJSON (/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/service.js:79:35)
    at /home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/namespace.js:131:50
    at Array.forEach (native)
    at Namespace.addJSON (/home/paralin/Documents/fusecloud-ng/grpc-bus/node_modules/protobufjs/src/namespace.js:127:33)

Proto:

In "compiled" inline JS object:

/* tslint:disable:trailing-comma */
/* tslint:disable:quotemark */
/* tslint:disable:max-line-length */
export const PROTO_DEFINITIONS = {
  "nested": {
    "mock": {
      "nested": {
        "Greeter": {
          "methods": {
            "SayHello": {
              "requestType": "HelloRequest",
              "responseType": "HelloReply"
            },
            "SayHelloClientStream": {
              "requestType": "HelloRequest",
              "requestStream": true,
              "responseType": "HelloReply"
            },
            "SayHelloServerStream": {
              "requestType": "HelloRequest",
              "responseType": "HelloReply",
              "responseStream": true
            },
            "SayHelloBidiStream": {
              "requestType": "HelloRequest",
              "requestStream": true,
              "responseType": "HelloReply",
              "responseStream": true
            }
          }
        },
        "EDummyEnum": {
          "values": {
            "DUMMY": 0
          }
        },
        "HelloRequest": {
          "fields": {
            "name": {
              "type": "string",
              "id": 1
            }
          }
        },
        "HelloReply": {
          "fields": {
            "message": {
              "type": "string",
              "id": 1
            }
          }
        }
      }
    }
  }
};

When I try to load it with fromJSON I get the error above. The error output has a bit of extra output I put in when debugging the issue. The "type" argument is undefined, probably because the methods do not have a "type" field on them from the pbjs output.

Fix: either put "rpc" in the type field in the pbjs output, or default "undefined" -> "rpc".

@dcodeIO dcodeIO closed this in 98a58d4 Dec 7, 2016

@dcodeIO dcodeIO added the bug label Dec 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment