metaverse / truss

Truss helps you build go-kit microservices without having to worry about writing or maintaining boilerplate code.
Other
734 stars 143 forks source link

How to fix the warning Abc.Xyz is a non-base type specified to be located outside of the body? #342

Closed henry-infevo closed 2 years ago

henry-infevo commented 2 years ago

I got the warning below when trying to generate *.proto file.

WARN[0001] Abc.Items is a non-base type specified to be located outside of the body. Non-base types outside the body may result in generated code which fails to compile. 
WARN[0001] Code formatting error, generated service will not build, outputting unformatted code  error="687:1: expected statement, found '%' (and 5 more errors)"

And I get compiled error on generated file. *.pb.go

My protobuf message look like this

    rpc Abc (AbcRequest) returns (AbcResponse) {
        option (google.api.http) = {
          post: "an-endpoint"
        };
    }

       message AbcRequest {
    string field1 = 1;
    string field2 = 2;
    repeated Item items = 3;
      }

      message Item {
    string name = 1;
    }
zaquestion commented 2 years ago

It means that you used a type, that may not work reliably as a query param (tho most cases work fine, except nesting at this point). That said assuming based on you going for a POST request, you probably want the params in the body and are confused why you're getting this error.

the pb annotations actually make you specify what goes in the body explicitly. add body: "*" (pretty sure its quoted)

option (google.api.http) = {
          post: "an-endpoint"
                  body: "*" 
        };
henry-infevo commented 2 years ago

Yeah, I debugged truss and found the issue as your suggestion.

Thank @zaquestion